要回答你的问题$ rootScope。$$阶段可以设置为“空”(串),这将导致引发此错误。
我不知道你是如何捕捉到这条消息的,但是Sentry报告说,对于我和我从一堆用户那里得到大量的异常。
所以为了减少the spam我做了一个函数,将异常删除堆栈,将清除$ rootScope $$阶段希望这将阻止第二次出现:
function exceptionHandler(){
const error = Error;
const nullMessage = "[$rootScope:inprog] null already in progress";
function exception(message){
if(message.indexOf(nullMessage) === 0){
const $rootScope = exceptionHandler.$rootScope;
if($rootScope) $rootScope.$$phase = null;
const exception = new error(nullMessage);
exception.stack = "";
return exception;
}
return new error(message);
}
Error = exception;
}
exceptionHandler(); // If it's not run AngularJS will use the original Error constructor, the one we're decorating
然后在angular.run注入$ rootScope并将其设置为功能的属性:
angular.run(["$rootScope", function($rootScope){
exceptionHandler.$rootScope = $rootScope;
}]);
我的假设是,扩展设置为$ rootScope。$$阶段到“null”但在安装与我的一个用户相同的扩展后,未发生异常。
Star on GistHub
为错误的文档,请访问https://docs.angularjs.org/error/$rootScope/inprog – georgeawg
我得到通过我们的监控软件报告了类似的问题 - 出现这种情况,如果只有这样,你传递一个包含'null'作为函数参数的字符串。问题是beginPhase()在整个角度源中只调用两次 - 在两种情况下都需要'$ apply'或'$ digest'。所以,尽管这是一个线索,但我仍然难以确定导致这种情况发生的原因。 – Veetek