angular2-notifications icon indicating copy to clipboard operation
angular2-notifications copied to clipboard

ViewDeestroyedError when click closing notification

Open CHBaker opened this issue 7 years ago • 7 comments

Hey, I'm getting this error when I click the notification for it to disappear.

Uncaught Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges
    at viewDestroyedError (core.js:9800)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:14652)
    at checkAndUpdateView (core.js:13802)
    at callWithDebugContext (core.js:15056)
    at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:14593)
    at ViewRef_.detectChanges (core.js:11577)
    at eval (angular2-notifications.umd.js:535) <----------- HERE
    at ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:4749)
    at ZoneDelegate.invoke (zone.js:387)

This is very bad for performance as this error hits 365 times in my app because it executes change detection though the entire component tree. This error is coming from Angular's changed detection running right after it's destroyed, looking for it. I'm not sure how to fix it though, or prevent it maybe in the source code for angular2-notifications

CHBaker avatar Mar 01 '18 19:03 CHBaker

I had the same issue today.

pmitrifork avatar Mar 06 '18 21:03 pmitrifork

I'd be happy to submit a pull request, I just couldn't find in the source code where I could add the onDestroy hook and what to unsubscribe from

CHBaker avatar Mar 12 '18 16:03 CHBaker

Any fix for that ?

Frisky- avatar Apr 16 '18 11:04 Frisky-

I'm unable to recreate this one. If someone can help set up the recreated error https://stackblitz.com. I can start debugging.

flauc avatar Apr 16 '18 11:04 flauc

I can try to recreate it next week, I know it has to do with a subscription that is not unsubscribed from in the source code, It might be caused by lazy loaded routes

CHBaker avatar Apr 16 '18 16:04 CHBaker

I don't know if it's necessarily related to lazy loaded routes as I'm also seeing this error and do not have lazy loaded routes in my app.

I'm not able to reproduce this issue reliably, but when it does fail, it fails spectacularly and crashes the entire app.

davidalee avatar Apr 28 '18 16:04 davidalee

yes @davidalee you're right as far as I can tell it isn't connected. It looks like it errors out when the notification is manually destroyed at the same time as it's being animated out.

flauc avatar Apr 28 '18 18:04 flauc