Search code examples
angularzonejs

UnsubscriptionError thrown on first RX subscription


I am developing an Angular2 app for a couple of weeks now, and I ran into this a couple of days back.

The issue happens on the very first call to subscribe or toPromise on an rxJS stream, and doesn't seem to break app behaviour at all. It does, however, throw in the browser's console output, and seems to prevent debugging ( because the connection is lost between zone.js and the app? )

This happens regardless of which subscription is loaded first, and both in Google chrome and firefox alike.

I will try and update this question if I get more info, but at the moment this is all I know.

Very useless stacktrace:

browser_adapter.js:76 EXCEPTION: 
UnsubscriptionErrorBrowserDomAdapter.logError @ browser_adapter.js:76
BrowserDomAdapter.logGroup @ browser_adapter.js:86
ExceptionHandler.call @ exception_handler.js:56
(anonymous function) @ application_ref.js:193
schedulerFn @ async.js:122
SafeSubscriber.__tryOrUnsub @ Subscriber.js:166
SafeSubscriber.next @ Subscriber.js:115
Subscriber._next @ Subscriber.js:74
Subscriber.next @ Subscriber.js:51
Subject._finalNext @ Subject.js:124
Subject._next @ Subject.js:116
Subject.next @ Subject.js:73
EventEmitter.emit @ async.js:11
1NgZone._zoneImpl.ng_zone_impl_1.NgZoneImpl.onError @ ng_zone.js:119
NgZoneImpl.inner.inner.fork.onHandleError @ ng_zone_impl.js:65
ZoneDelegate.handleError @ zone.js:364
Zone.runTask @ zone.js:293
ZoneTask.invoke @ zone.js:460
XMLHttpRequest.send (async)scheduleTask @ zone.js:100
ZoneDelegate.scheduleTask @ zone.js:373
Zone.longStackTraceZoneSpec.onScheduleTask @ long-stack-trace-zone.js:119
ZoneDelegate.scheduleTask @ zone.js:370
Zone.scheduleMacroTask @ zone.js:310
(anonymous function) @ zone.js:121
send @ VM76503:3(
anonymous function) @ xhr_backend.js:76
Observable.subscribe @ Observable.js:58
Observable._subscribe @ Observable.js:99
Observable.subscribe @ Observable.js:55
Observable._subscribe @ Observable.js:99
Observable.subscribe @ Observable.js:55
AccountScreen.routerOnActivate @ account_screen.ts:56
(anonymous function) @ router_outlet.js:67
ZoneDelegate.invoke @ zone.js:36
0NgZoneImpl.inner.inner.fork.onInvoke @ ng_zone_impl.js:44
ZoneDelegate.invoke @ zone.js:359
Zone.run @ zone.js:253
(anonymous function) @ zone.js:605
ZoneDelegate.invokeTask @ zone.js:393
NgZoneImpl.inner.inner.fork.onInvokeTask @ ng_zone_impl.js:35
ZoneDelegate.invokeTask @ zone.js:392
Zone.runTask @ zone.js:290
drainMicroTaskQueue @ zone.js:511
ZoneTask.invoke @ zone.js:463

Solution

  • It seems to be a bug with zone.js. The last few betas of Angular depend on zone.js@^0.6.6which resolves to 0.6.9, which seems to be buggy.

    Rolling back to 0.6.6 clears up the issue. A github issue has created here.