我一直在尝试向仅在Chrome上运行的Web应用程序添加一些更好的错误日志记录。本质上,我希望能够捕获和存储堆栈跟踪。对于同步代码,这很好用,但是对于异步代码,我遇到了一些奇怪的事情。本质上,Chrome似乎将其他信息记录为异步堆栈跟踪功能的一部分,但我一直无法弄清楚如何捕获它。
在Chrome浏览器控制台中运行的代码:
let e;
let a = () => Promise.resolve(null)
.then(() => (null).foo)
.catch(err => {
console.info(err);
console.error(err);
e = err;
})
let b = () => a();
let c = () => b();
c();
Run Code Online (Sandbox Code Playgroud)
输出:
(info)
TypeError: Cannot read property 'foo' of null
at <anonymous>:3:20
(error, after expanding)
TypeError: Cannot read property 'foo' of null
at <anonymous>:3:20
(anonymous) @ VM1963:6
Promise.catch (async)
a @ VM1963:4
b @ VM1963:9
c @ VM1963:10
(anonymous) @ VM1963:11
Run Code Online (Sandbox Code Playgroud)
因此,console.error给了我一个一直贯穿整个调用栈的堆栈跟踪信息,大概是某种形式的Chrome引擎magick。console.info给了我存储在上的实际堆栈跟踪 …
基本上,无论出于何种原因,pycharm的语法高亮/着色都不起作用; 所有文字都显示为纯黑色.尽管根据我的编辑器设置,在IDE设置 - >编辑器 - >颜色和字体 - >常规下,突出显示/着色似乎已打开并正确定义.谁能告诉我如何正确启用它?谢谢!
我有一个使用ui.router包构建的Angular应用程序用于URL路由.我想更改它,以便如果用户尝试导航到他们已经在的页面,路由器将重新加载该状态而不是什么都不做.根据http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$ state#go,$ state.go 确实采用了一个重新加载参数,但是这样做的确如此它默认为false.现在,在我的代码中重写每个调用$ state.go和每个ui-sref以将reload设置为true的想法都是一个糟糕的想法.我想要的是改变$ state.go的那个参数的默认值的一些方法,或者至少是ui-sref装饰器.
在http://angular-tips.com/blog/2013/09/experiment-decorating-directives/之后,我尝试至少扩展ui-sref指令(因为除了明确的指令之外还有更多的指令) $ state.go电话)
myApp.config(function($provide) {
// override ui-sref to have the reload option default to true.
$provide.decorator('uiSrefDirective', function($delegate){
var directive = $delegate[0];
var link = directive.link;
directive.compile = function() {
return function(scope, element, attrs) {
if(attrs.uiSrefOpts == null){
attrs.uiSrefOpts = {};
}
if(attrs.uiSrefOpts.reload == null){
attrs.uiSrefOpts.reload = true;
}
console.log(arguments);
link.apply(this, arguments);
};
};
return $delegate;
});
Run Code Online (Sandbox Code Playgroud)
然而,这实际上似乎没有任何成就,即使它确实如此,它实际上也不会影响$ state.go.有没有人有任何想法如何在ui.router代码中手动更改这种行为?
自从我升级到 Big Sur 后,我注意到每当我运行 Jest 测试时,Sophos 就会开始显着干扰。即使运行一个普通的 Jest 测试程序,Sophos 的 CPU 使用率也会飙升至 400% 左右,目前 71 个测试的运行时间为 98.6 秒。Jest 进程完成后,Sophos 将返回睡眠状态,不再占用大量资源。
我使用 Node.js 从终端运行这些测试。我的假设是,问题实际上是 Node 和 Sophos 之间的问题,而且 Jest 运行测试的方式加剧了问题。
以前有人遇到过这个问题吗?我能做些什么来说服 Sophos 放弃 Node 吗?
就其价值而言,测试本身是标准的 JS 和 React 单元测试,React 测试是使用 React 测试库编写的。