angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

ObjectUnsubscribedError pointing to private router: Router in constructor #439

Closed cyphercodes96 closed 6 years ago

cyphercodes96 commented 6 years ago

Hello, i've been tracking down this issue on my application for a while now. I've reverted from using eventEmitters to Subjects and Observables, unsubscribed to any pending http requests on ngOnDestroy(){} This error i've been able of replicating when navigating between components inside my application My Error:

defaultErrorLogger | @ | core.js:1448   | ErrorHandler.handleError | @ | core.js:1509   | next | @ | core.js:5497   | schedulerFn | @ | core.js:4331   | SafeSubscriber.tryOrUnsub | @ | Subscriber.js:240   | SafeSubscriber.next | @ | Subscriber.js:187   | Subscriber._next | @ | Subscriber.js:128   | Subscriber.next | @ | Subscriber.js:92   | Subject.next | @ | Subject.js:56   | EventEmitter.emit | @ | core.js:4311   | (anonymous) | @ | core.js:4771   | ZoneDelegate.invoke | @ | zone.js:388   | Zone.run | @ | zone.js:138   | NgZone.runOutsideAngular | @ | core.js:4697   | onHandleError | @ | core.js:4771   | ZoneDelegate.handleError | @ | zone.js:392   | Zone.runTask | @ | zone.js:191   | ZoneTask.invokeTask | @ | zone.js:496   | invokeTask | @ | zone.js:1517   | globalZoneAwareCallback | @ | zone.js:1543   | XMLHttpRequest.send (async) |   |     | scheduleTask | @ | zone.js:2935   | ZoneDelegate.scheduleTask | @ | zone.js:407   | onScheduleTask | @ | zone.js:297   | ZoneDelegate.scheduleTask | @ | zone.js:401   | Zone.scheduleTask | @ | zone.js:232   | Zone.scheduleMacroTask | @ | zone.js:255   | scheduleMacroTaskWithCurrentZone | @ | zone.js:1092   | (anonymous) | @ | zone.js:2967   | proto.(anonymous function) | @ | zone.js:1372   | (anonymous) | @ | http.js:2366   | Observable._trySubscribe | @ | Observable.js:172   | Observable.subscribe | @ | Observable.js:160   | subscribeToResult | @ | subscribeToResult.js:23   | MergeMapSubscriber._innerSub | @ | mergeMap.js:138   | MergeMapSubscriber._tryNext | @ | mergeMap.js:135   | MergeMapSubscriber._next | @ | mergeMap.js:118   | Subscriber.next | @ | Subscriber.js:92   | ScalarObservable._subscribe | @ | ScalarObservable.js:51   | Observable.trySubscribe | @ | Observable.js:172   | Observable.subscribe | @ | Observable.js:160   | MergeMapOperator.call | @ | mergeMap.js:92   | Observable.subscribe | @ | Observable.js:157   | FilterOperator.call | @ | filter.js:61   | Observable.subscribe | @ | Observable.js:157   | MapOperator.call | @ | map.js:57   | Observable.subscribe | @ | Observable.js:157   | DentalChartComponent.getCharts | @ | dental-chart.component.ts:67   | DentalChartComponent.ngOnInit | @ | dental-chart.component.ts:47   | checkAndUpdateDirectiveInline | @ | core.js:12369   | checkAndUpdateNodeInline | @ | core.js:13893   | checkAndUpdateNode | @ | core.js:13836   | debugCheckAndUpdateNode | @ | core.js:14729   | debugCheckDirectivesFn | @ | core.js:14670   | (anonymous) | @ | DentalChartComponent…gfactory.js? [sm]:1   | debugUpdateDirectives | @ | core.js:14655   | checkAndUpdateView | @ | core.js:13802   | callViewAction | @ | core.js:14153   | execEmbeddedViewsAction | @ | core.js:14111   | checkAndUpdateView | @ | core.js:13803   | callViewAction | @ | core.js:14153   | execComponentViewsAction | @ | core.js:14085   | checkAndUpdateView | @ | core.js:13808   | callViewAction | @ | core.js:14153   | execEmbeddedViewsAction | @ | core.js:14111   | checkAndUpdateView | @ | core.js:13803   | callViewAction | @ | core.js:14153   | execComponentViewsAction | @ | core.js:14085   | checkAndUpdateView | @ | core.js:13808   | callWithDebugContext | @ | core.js:15056   | debugCheckAndUpdateView | @ | core.js:14593   | ViewRef.detectChanges | @ | core.js:11577   | (anonymous) | @ | core.js:5907   | ApplicationRef.tick | @ | core.js:5907   | (anonymous) | @ | core.js:5740   | ZoneDelegate.invoke | @ | zone.js:388   | onInvoke | @ | core.js:4749   | ZoneDelegate.invoke | @ | zone.js:387   | Zone.run | @ | zone.js:138   | NgZone.run | @ | core.js:4566   | next | @ | core.js:5740   | schedulerFn | @ | core.js:4331   | SafeSubscriber.tryOrUnsub | @ | Subscriber.js:240   | SafeSubscriber.next | @ | Subscriber.js:187   | Subscriber._next | @ | Subscriber.js:128   | Subscriber.next | @ | Subscriber.js:92   | Subject.next | @ | Subject.js:56   | EventEmitter.emit | @ | core.js:4311   | checkStable | @ | core.js:4714   | onHasTask | @ | core.js:4762   | ZoneDelegate.hasTask | @ | zone.js:441   | ZoneDelegate._updateTaskCount | @ | zone.js:461   | Zone._updateTaskCount | @ | zone.js:285   | Zone.runTask | @ | zone.js:205   | drainMicroTaskQueue | @ | zone.js:595   | ZoneTask.invokeTask | @ | zone.js:500   | ZoneTask.invoke | @ | zone.js:485   | timer | @ | zone.js:2025   | setTimeout (async) |   |     | scheduleTask | @ | zone.js:2046   | ZoneDelegate.scheduleTask | @ | zone.js:407   | onScheduleTask | @ | zone.js:297   | ZoneDelegate.scheduleTask | @ | zone.js:401   | Zone.scheduleTask | @ | zone.js:232   | Zone.scheduleMacroTask | @ | zone.js:255   | scheduleMacroTaskWithCurrentZone | @ | zone.js:1092   | (anonymous) | @ | zone.js:2061   | proto.(anonymous function) | @ | zone.js:1372   | (anonymous) | @ | router.js:4831   | schedulerFn | @ | core.js:4331   | SafeSubscriber.__tryOrUnsub | @ | Subscriber.js:240   | SafeSubscriber.next | @ | Subscriber.js:187   | Subscriber._next | @ | Subscriber.js:128   | Subscriber.next | @ | Subscriber.js:92   | Subject.next | @ | Subject.js:56   | EventEmitter.emit | @ | core.js:4311   | (anonymous) | @ | common.js:172   | ZoneDelegate.invokeTask | @ | zone.js:421   | onInvokeTask | @ | core.js:4740   | ZoneDelegate.invokeTask | @ | zone.js:420   | Zone.runTask | @ | zone.js:188   | ZoneTask.invokeTask | @ | zone.js:496   | invokeTask | @ | zone.js:1517   | globalZoneAwareCallback | @ | zone.js:1543

which is leading me to lines 47 and 67 in my chart component lines 44 --> 52 : constructor(private categoryService: CategoryListService, private dropDownService: DropDownService, private route: ActivatedRoute, private router: Router, private api: PatientsService, private auth: AuthenticationService, public sanitizer: DomSanitizer, private chart: ChartService, public location: Location) {

lines 63 --> 68 : this.treatmentPlanId = +route.snapshot.params['id']; this.sub = this.chart.gotChartId.subscribe((id) => { this.chartId = id; this.categories = this.categoryService.getAllCategories(); this.planMode = true; this.getChartItem();

Could this be an issue with the router package itself?