diff options
| author | Igor Minar | 2011-10-30 15:11:25 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-10-31 11:34:25 -0700 | 
| commit | ef875ad0cf4349144cb4674e050dd160564f6dd9 (patch) | |
| tree | 77b5aaac971cb6a5b2e43504db8886b9877da89b /src/Scope.js | |
| parent | 615841a5d3cb6dae8329411c27fd938e9b413f4c (diff) | |
| download | angular.js-ef875ad0cf4349144cb4674e050dd160564f6dd9.tar.bz2 | |
feat(scope): better logging of infinite digest error
Feedback team has often problems debugging inifinite digest errors, this change
should reveal info about what watchers are causing the infinite loop
Diffstat (limited to 'src/Scope.js')
| -rw-r--r-- | src/Scope.js | 17 | 
1 files changed, 14 insertions, 3 deletions
| diff --git a/src/Scope.js b/src/Scope.js index be5030cc..c4b9513b 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -260,7 +260,8 @@ Scope.prototype = {          watcher = {            fn: listenFn,            last: Number.NaN, // NaN !== NaN. We used this to force $watch to fire on first run. -          get: get +          get: get, +          exp: watchExp          };      if (!array) { @@ -325,7 +326,8 @@ Scope.prototype = {          asyncQueue,          length,          dirty, ttl = 100, -        next, current, target = this; +        next, current, target = this, +        watchLog = [];      if (target.$$phase) {        throw Error(target.$$phase + ' already in progress'); @@ -356,6 +358,14 @@ Scope.prototype = {                  dirty = true;                  watch.last = copy(value);                  watch.fn(current, value, last); +                if (ttl < 5) { +                  if (!watchLog[4-ttl]) watchLog[4-ttl] = []; +                  if (isFunction(watch.exp)) { +                    watchLog[4-ttl].push('fn: ' + (watch.exp.name || watch.exp.toString())); +                  } else { +                    watchLog[4-ttl].push(watch.exp); +                  } +                }                }              } catch (e) {                current.$service('$exceptionHandler')(e); @@ -376,7 +386,8 @@ Scope.prototype = {        } while ((current = next));        if(!(ttl--)) { -        throw Error('100 $digest() iterations reached. Aborting!'); +        throw Error('100 $digest() iterations reached. Aborting!\n' + +            'Watchers fired in the last 5 iterations: ' + toJson(watchLog));        }      } while (dirty);    }, | 
