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(ngUpgrade): make AoT ngUpgrade work with the testability API and resumeBootstrap() #12910

Merged
merged 1 commit into from
Nov 16, 2016

Conversation

sjelin
Copy link
Contributor

@sjelin sjelin commented Nov 16, 2016

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x")

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

In apps using ngUpgrade and AoT compilation, resumeBootstrap causes config and run blocks to be run outside NgZone, which in turn causes problems with change detection. Additionally, the testability APIs of ng1 and ng2 were not hooked together properly.

What is the new behavior?

resumeBootstrap is patched to always run inside the NgZone, ng1 testability API is decorated to wait on the ng2 API.

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[x] No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

I have no idea why the second test in modules/@angular/upgrade/test/aot/integration/testability_spec.ts was passing but I verified using a sample app that the decoration of the ng1 testability API was nessisary

@sjelin sjelin force-pushed the static-upgrade branch 2 times, most recently from eeddddb to 176a89f Compare November 16, 2016 06:49
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

This looks great, @sjelin! Thanks for staying up late and putting this together.

@@ -59,7 +91,22 @@ export class UpgradeModule {
}
]);

// Make sure resumeBootstrap() only exists if the current bootstrap is deferred
const windowAngular = (window as any /** TODO #???? */)['angular'];
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a valid use of any so no need for the TODO comment

@petebacondarwin petebacondarwin added comp: upgrade type: bug/fix freq3: high action: merge The PR is ready for merge by the caretaker regression Indicates than the issue relates to something that worked in a previous version labels Nov 16, 2016
@petebacondarwin
Copy link
Member

I can confirm that this fixes the problem with #12717

@vicb vicb merged commit 42198cd into angular:master Nov 16, 2016
petebacondarwin pushed a commit to petebacondarwin/angular that referenced this pull request Nov 16, 2016
sjelin added a commit to sjelin/angular that referenced this pull request Nov 16, 2016
…tstrap

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable

Neither of the above problems with non-static apps were actually causing bugs (as far as I know),
but they *might* have caused problems in the future.

Inspired by angular#12910, but for non-static apps.
sjelin added a commit to sjelin/angular that referenced this pull request Nov 16, 2016
…tstrap

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable
* Updated static example to get type mocks for ng1

Neither of the first twp problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.  The example had to be updated to make the tests pass (no idea
why this change mattered).

Inspired by angular#12910, but for non-static apps.
sjelin added a commit to sjelin/angular that referenced this pull request Nov 16, 2016
…tstrap

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable
* Updated static example to get type mocks for ng1

Neither of the first two problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.  The example had to be updated to make the tests pass (no idea
why this change mattered to that example).

Inspired by angular#12910, but for non-static apps.
sjelin added a commit to sjelin/angular that referenced this pull request Nov 16, 2016
…tstrap

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable
* Updated static example to get type mocks for ng1

Neither of the first two problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.  The example had to be updated to make the tests pass (no idea
why this change mattered to that example).

Inspired by angular#12910, but for non-static apps.
sjelin added a commit to sjelin/angular that referenced this pull request Nov 16, 2016
…tstrap

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable

Neither of the first two problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.

Inspired by angular#12910, but for non-static apps.
chuckjaz pushed a commit that referenced this pull request Nov 17, 2016
alexeagle pushed a commit to alexeagle/angular that referenced this pull request Nov 17, 2016
chuckjaz pushed a commit that referenced this pull request Nov 18, 2016
…tstrap (#12926)

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable

Neither of the first two problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.

Inspired by #12910, but for non-static apps.
chuckjaz pushed a commit that referenced this pull request Nov 22, 2016
…tstrap (#12926)

* With non-static ngUpgrade apps, callbacks to `whenStable` were being invoked with the wrong
  context
* With non-static ngUpgrade apps, `resumeBootstrap` was being run outside the NgZone
* Remove redundent `whenStableContext` variable

Neither of the first two problems were actually causing bugs (as far as I know), but they *might*
have caused problems in the future.

Inspired by #12910, but for non-static apps.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes freq3: high regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants