-
Notifications
You must be signed in to change notification settings - Fork 26.2k
fix(router): error if module is destroyed before location is initialized #42560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (this.destroyed) { | ||
return Promise.resolve(true); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way of solving this would be to pull the injector.get
calls outside of the callback. I decided against it, because I wasn't sure if the Router
and RouterConfiguration
would be available earlier in the lifecycle.
This is something I ran into while working on a fix for the `TestBed` module teardown behavior for angular#18831. In the `RouterInitializer.appInitializer` we have a callback to the `LOCATION_INITIALIZED` which has to do some DI lookups. The problem is that if the module is destroyed before the location promise resolves, the `Injector.get` calls will fail. This is unlikely to happen in a real app, but it'll show up in unit tests once the test module teardown behavior is fixed.
535689d
to
853d031
Compare
…zed (#42560) This is something I ran into while working on a fix for the `TestBed` module teardown behavior for #18831. In the `RouterInitializer.appInitializer` we have a callback to the `LOCATION_INITIALIZED` which has to do some DI lookups. The problem is that if the module is destroyed before the location promise resolves, the `Injector.get` calls will fail. This is unlikely to happen in a real app, but it'll show up in unit tests once the test module teardown behavior is fixed. PR Close #42560
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This is something I ran into while working on a fix for the
TestBed
module teardown behavior for #18831. In theRouterInitializer.appInitializer
we have a callback to theLOCATION_INITIALIZED
which has to do some DI lookups. The problem is that if the module is destroyed before the location promise resolves, theInjector.get
calls will fail. This is unlikely to happen in a real app, but it'll show up in unit tests once the test module teardown behavior is fixed.