Since updating my app to Angular 12, I've been encountering an unusual error message every time I move away from a component that has ngOnDestroy function with .unsubscribe() calls. What's even more peculiar is that the teardown.unsubscribe mentioned in the error isn't present anywhere in my project, which is making it quite challenging to troubleshoot.
ERROR Error: Uncaught (in promise): UnsubscriptionError: 1 errors occurred during unsubscription:
1) TypeError: teardown.unsubscribe is not a function
Error
at _super (createErrorClass.js:4)
at new UnsubscriptionErrorImpl (UnsubscriptionError.js:3)
at SafeSubscriber.unsubscribe (Subscription.js:55)
at SafeSubscriber.unsubscribe (Subscriber.js:55)
at FooComponent.ngOnDestroy (my-foo.component.ts:58)
at executeOnDestroys (core.js:7406)
at cleanUpView (core.js:7309)
at destroyViewTree (core.js:7142)
at destroyLView (core.js:7287)
at RootViewRef.destroy (core.js:22651)
at resolvePromise (zone.js:1213)
at resolvePromise (zone.js:1167)
at zone.js:1279
at ZoneDelegate.invokeTask (zone.js:406)
at Object.onInvokeTask (core.js:28667)
at ZoneDelegate.invokeTask (zone.js:405)
at Zone.runTask (zone.js:178)
at drainMicroTaskQueue (zone.js:582)
at ZoneTask.invokeTask [as invoke] (zone.js:491)
at invokeTask (zone.js:1600)
my-foo.component.ts
57: ngOnDestroy(): void {
58: this.aSubscription$?.unsubscribe();
59: this.bSubscription$?.unsubscribe();
60: this.cSubscription$?.unsubscribe();
61: this.dSubscription$?.unsubscribe();
62: }