umbraco-community / umbraco-analytics

Google Analytics for the Umbraco CMS
40 stars 31 forks source link

$digest errors for the settings controller #28

Open abjerner opened 9 years ago

abjerner commented 9 years ago

I'm getting an error in the backoffice with the last code from the develop branch:

Error: $digest already in progress
    at Error (native)
    at g (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:87:165)
    at Object.$get.e.$apply (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:92:362)
    at http://localhost:52607/App_Plugins/Analytics/backoffice/analyticstree/controllers/settings.controller.js:40:20
    at j.promise.then.i (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:79:437)
    at j.promise.then.i (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:79:437)
    at j.promise.then.i (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:79:437)
    at j.promise.then.i (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:79:437)
    at http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:80:485
    at Object.$get.e.$eval (http://localhost:52607/umbraco/lib/angular/1.1.5/angular.min.js:92:272)

Which is around these lines:

            //Apply
            $scope.$apply(function () {
                $scope.hasAuthd = hasUserAuthd;
            });

Currently it seems to prevent me from authorizing when already authorizing. At least nothing happens, so I assume it is because the controller isn't fully initialized. Not sure whether this also results in other errors.

warrenbuckley commented 9 years ago

OK maybe me or @bjarnef can take a look into why this is happening. But ultimately the error is quite descriptive and that an Angular Scope DIgest is already processing/updating values whilst this manual/forced way of telling the model to update with $apply seems to be happening whilst another update is going on.

bjarnef commented 9 years ago

@warrenbuckley I think I have seen this error for a while.. or is it something new?

abjerner commented 9 years ago

I think I first noticed it about a week ago, but it didn't seem to cause any errors at the time. Also I'm not sure these two errors are related - just wanted to post i here before I'd forget about it.

konius commented 8 years ago

I am getting the same error and can't use the Analytics with Umbraco 7.3.4. Anyone solved this?

bjarnef commented 7 years ago

Some suggestion although I haven't tested these:

http://stackoverflow.com/questions/14838184/error-digest-already-in-progress

$timeout(function() {
  $scope.hasAuthd = hasUserAuthd;
});

or

$scope.$evalAsync(function(){ 
  $scope.hasAuthd = hasUserAuthd;
});

or maybe safeApply in angularHelper: https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web.UI.Client/src/common/services/angularhelper.service.js#L40

Like this: https://github.com/umbraco/Umbraco-CMS/blob/5397f2c53acbdeb0805e1fe39fda938f571d295a/src/Umbraco.Web.UI.Client/src/views/propertyeditors/colorpicker/multicolorpicker.controller.js#L27-L29

Emetico commented 6 years ago

Hi Bjarnef.

$timeout(function() {
  $scope.hasAuthd = hasUserAuthd;
});

Seems to fix it. I nolonger get the error.