Angular 6神秘的堆栈跟踪:globalZoneAwareCallback

时间:2018-10-08 03:03:07

标签: javascript angular6 angular-router

最近,使用Angular6,我开始在浏览器控制台中观察到描述性极差的堆栈跟踪:

  

ERROR错误:“ [对象对象]”
  resolvePromise
  http://localhost:8080/polyfills.js:3136:31 resolvePromise
  http://localhost:8080/polyfills.js:3093:17 scheduleResolveOrReject
  http://localhost:8080/polyfills.js:3195:17 invokeTask
  http://localhost:8080/polyfills.js:2743:17 onInvokeTask
  http://localhost:8080/vendor.js:36899:24 invokeTask
  http://localhost:8080/polyfills.js:2742:17 runTask
  http://localhost:8080/polyfills.js:2510:28 raineMicroTaskQueue
  http://localhost:8080/polyfills.js:2917:25 invokeTask
  http://localhost:8080/polyfills.js:2822:21 invokeTask
  http://localhost:8080/polyfills.js:3862:9 globalZoneAwareCallback
  http://localhost:8080/polyfills.js:3888:17 core.js:1673
  defaultErrorLogger
  core.js:1673
  ./node_modules/@angular/core/fesm5/core.js
  /ErrorHandler.prototype.handleError
  core.js:1719
  下一个
  core.js:4319:109
  ./node_modules/@angular/core/fesm5/core.js
  /EventEmitter.prototype.subscribe/schedulerFn << br />   core.js:3555:34
  ./node_modules/rxjs/_esm5/internal/Subscriber.js
  /SafeSubscriber.prototype.__tryOrUnsub
  Subscriber.js:195
  ./node_modules/rxjs/_esm5/internal/Subscriber.js
  /SafeSubscriber.prototype.next
  Subscriber.js:133
  ./node_modules/rxjs/_esm5/internal/Subscriber.js
  /Subscriber.prototype._next
  Subscriber.js:77
  ./node_modules/rxjs/_esm5/internal/Subscriber.js
  /Subscriber.prototype.next
  Subscriber.js:54
  ./node_modules/rxjs/_esm5/internal/Subject.js/Subject.prototype.next
  Subject.js:47
  ./node_modules/@angular/core/fesm5/core.js/EventEmitter.prototype.emit
  core.js:3539:52
  onHandleError / << br />   core.js:3846:48
  ./node_modules/zone.js/dist/zone.js/   zone.js:388
  ./node_modules/zone.js/dist/zone.js/   zone.js:138
  ./node_modules/@angular/core/fesm5/core.js
  /NgZone.prototype.runOutsideAngular
  core.js:3783
  onHandleError
  core.js:3846
  ./node_modules/zone.js/dist/zone.js
  /   zone.js:392
  ./node_modules/zone.js/dist/zone.js/   zone.js:154
  _loop_1
  zone.js:677
  ./node_modules/zone.js/dist/zone.js/   zone.js:686
  rainMicroTaskQueue
  zone.js:602
  ./node_modules/zone.js/dist/zone.js/   zone.js:500
  invokeTask
  zone.js:1540
  globalZoneAwareCallback
  zone.js:1566

我怀疑路由模块中存在一些错误,因此我粘贴了配置:

const routes = [
  {
    path: 'wordspreview/:id',
    component: WordsPreviewComponent
  },
  {
    path: 'wordspreview',
    component: WordsPreviewComponent
  },
  {
    path: 'search/:query',
    component: SearchResultsComponent
  },
  {
    path: '',
    redirectTo: '/wordspreview',
    pathMatch: 'full'
  }
};

希望有人可以提供帮助。

1 个答案:

答案 0 :(得分:0)

我刚刚发现了这个错误。

无法在其他任何地方使用Google,我将在此处留下解决方案以帮助下一个潜在受害者:

constructor(private router : Router,
[...]
this.router.navigate([site, id]);

我做错了是导航到错误的site。调试起来很困难,因为它只出现在一些罕见的错误site值上。