Skip to content
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

fix(router): lazy routing tries loading destroyed module #24987

Closed
wants to merge 5 commits into from

Conversation

kewde
Copy link

@kewde kewde commented Jul 19, 2018

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

The router can lazy load modules. It doesn't check whether that module has been destroyed or not.

Issue Number: #24962

What is the new behavior?

If it has been destroyed, it will create a new instance of it.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

I'm a complete noob to angular and I need this change 😘

@kewde kewde changed the title Lazy routing don't load destroyed module fix(router): lazy routing won't load destroyed module Jul 19, 2018
@kewde kewde force-pushed the fix-lazy-module-destroyed branch from a78f4b9 to a405be9 Compare July 19, 2018 23:15
@jasonaden jasonaden self-assigned this Sep 4, 2018
Copy link
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please squash down to 2 commits, with detailed and scoped commit messages for both. The first should add destroyed() in core, the second should make use of the feature in `apply_redirects.ts.

@kewde kewde force-pushed the fix-lazy-module-destroyed branch 3 times, most recently from 6759be2 to c106859 Compare September 12, 2018 16:45
@JoostK
Copy link
Member

JoostK commented Sep 12, 2018

This affects public API surface, so you will need to update the golden files of the public API. See CircleCI logging:

CircleCI summary
FAIL: //tools/public_api_guard:core_core_api (see /home/circleci/.cache/bazel/_bazel_circleci/9ce5c2144ecf75d11717c0aa41e45a8d/execroot/angular/bazel-out/k8-fastbuild/testlogs/tools/public_api_guard/core_core_api/test.log)

INFO: From Testing //tools/public_api_guard:core_core_api:

==================== Test output for //tools/public_api_guard:core_core_api:
--- tools/public_api_guard/core/core.d.ts	Golden file
+++ tools/public_api_guard/core/core.d.ts	Generated API
@@ -530,8 +530,9 @@
 }
 
 export declare abstract class NgModuleRef<T> {
     abstract readonly componentFactoryResolver: ComponentFactoryResolver;
+    abstract readonly destroyed: boolean;
     abstract readonly injector: Injector;
     abstract readonly instance: T;
     abstract destroy(): void;
     abstract onDestroy(callback: () => void): void;


Accept the new golden file:
  bazel run //tools/public_api_guard:core_core_api.accept

@kewde
Copy link
Author

kewde commented Sep 14, 2018

@JoostK Thanks, fixed.

@kewde
Copy link
Author

kewde commented Sep 14, 2018

Travis-CI is having issues unrelated to this PR:

Error: ENOSPC: no space left on device, watch '/home/travis/build/angular/angular/aio/content/examples/upgrade-phonecat-2-hybrid'

@jasonaden
Copy link
Contributor

Update on this issue: Overall this looks great. However, the change to the public API is a pretty big breaking change. It means any code implementing NgModuleRef needs to be updated. This is fine for the Angular repo of course, but it will break user code.

I'm looking at how we can get this rolled out so we can move forward and merge this PR. Thanks for the patience.

@kewde
Copy link
Author

kewde commented Sep 20, 2018

@jasonaden

Let me know if there is anything else I can do.

I don't like breaking user code either, if the general consensus is that this is not to be merged, then I would like to know an alternative proposals to fix this bug.

@jasonaden
Copy link
Contributor

Discussed this one and it looks like we might be able to make this change by updating a couple internal Google users who are implementing this API. So I think we can move forward on this one. Doing internal testing here:

Presubmit

@kewde
Copy link
Author

kewde commented Nov 19, 2018

@jasonaden Is there any plan moving forward? We have a feature that depends on this fix

NgModuleRef (core/src/render3):
When a module is destroyed, it will call all the on destroy callbacks. When finished it is set to null (default state is empty array []).
We use the state of the destroyCbs variable for our destroyed boolean getter.
---
NgModuleRef_ (core/src/view/):
provide getter for _destroyed variable.
---
@kewde kewde closed this Jan 21, 2019
@kewde kewde reopened this Jan 21, 2019
@kewde
Copy link
Author

kewde commented Jan 21, 2019

@jasonaden @alxhub is there anything left for me to do here? Please let me know, I would like this bug fixed.

@kewde kewde requested review from IgorMinar and a team as code owners January 21, 2019 14:30
@kewde
Copy link
Author

kewde commented Jan 21, 2019

I've added a test commit as it is the only way to retrigger CI, I will force delete it and force push.
The Travis PR only failed because ENOSPC (no space left).

@kewde kewde force-pushed the fix-lazy-module-destroyed branch 2 times, most recently from 6743e97 to 681b095 Compare January 21, 2019 14:59
@kewde
Copy link
Author

kewde commented Jan 21, 2019

Rebased the PR against the current master just to be a 100% sure.

@kewde kewde requested a review from a team as a code owner January 21, 2019 16:18
@kewde kewde changed the title fix(router): lazy routing won't load destroyed module fix(router): lazy routing tries loading destroyed module Jan 21, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jan 24, 2019
@kewde
Copy link
Author

kewde commented Jan 28, 2019

Oh god, review hell.

I suppose it's not worth breaking the public API over this, so I think #28405 will also do the trick.

@petebacondarwin
Copy link
Member

Closing in favour of #28405

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants