Skip to content

fix(compiler): correctly instantiate eager providers that are used vi… - #19558

Closed
tbosch wants to merge 2 commits into
angular:masterfrom
tbosch:fix_providers
Closed

tbosch wants to merge 2 commits into
angular:masterfrom
tbosch:fix_providers

Conversation

@tbosch

@tbosch tbosch commented Oct 4, 2017

Copy link
Copy Markdown
Contributor

…a Injector.get

This also fixes the problem that all NgModule instances
became lazy when using TestBed.overrideProvider.

Closes #15501

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] 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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[ ] No

Other information

@tbosch
tbosch requested a review from chuckjaz October 4, 2017 17:31
@tbosch tbosch added area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release hotlist: google and removed cla: yes labels Oct 4, 2017
@mary-poppins

Copy link
Copy Markdown

You can preview 1fa3687 at https://pr19558-1fa3687.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 6328cff at https://pr19558-6328cff.ngbuilds.io/.

@tbosch tbosch added the action: merge The PR is ready for merge by the caretaker label Oct 4, 2017
@mary-poppins

Copy link
Copy Markdown

You can preview 1c52a1d at https://pr19558-1c52a1d.ngbuilds.io/.

@tbosch tbosch removed the action: merge The PR is ready for merge by the caretaker label Oct 4, 2017
@mary-poppins

Copy link
Copy Markdown

You can preview 3575640 at https://pr19558-3575640.ngbuilds.io/.

@tbosch
tbosch force-pushed the fix_providers branch 2 times, most recently from 6831beb to d7ca43c Compare October 9, 2017 15:17
@mary-poppins

Copy link
Copy Markdown

You can preview d7ca43c at https://pr19558-d7ca43c.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 3434b82 at https://pr19558-3434b82.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 76483ed at https://pr19558-76483ed.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 6ce1a62 at https://pr19558-6ce1a62.ngbuilds.io/.

tbosch added 2 commits October 9, 2017 14:06
This allows use to fix `TestBed.overrideProvider` to keep imported `NgModule`s eager,
while allowing our users to still keep the old semantics until they have fixed their
tests.
@tbosch

tbosch commented Oct 9, 2017

Copy link
Copy Markdown
Contributor Author

@IgorMinar approves this change (talked offline).

@tbosch tbosch added the action: merge The PR is ready for merge by the caretaker label Oct 9, 2017
@chuckjaz chuckjaz added this to the Merge-queue milestone Oct 9, 2017
@chuckjaz chuckjaz closed this in 6ade68c Oct 10, 2017
chuckjaz pushed a commit that referenced this pull request Oct 10, 2017
…19558)

This allows use to fix `TestBed.overrideProvider` to keep imported `NgModule`s eager,
while allowing our users to still keep the old semantics until they have fixed their
tests.

PR Close #19558
chuckjaz pushed a commit that referenced this pull request Oct 11, 2017
chuckjaz pushed a commit that referenced this pull request Oct 11, 2017
…19558)

This allows use to fix `TestBed.overrideProvider` to keep imported `NgModule`s eager,
while allowing our users to still keep the old semantics until they have fixed their
tests.

PR Close #19558
@tbosch
tbosch deleted the fix_providers branch October 17, 2017 23:03
kara added a commit to kara/angular that referenced this pull request May 21, 2019
BREAKING CHANGE

In PR angular#19558, we fixed a bug in `TestBed.overrideProvider` where
eager providers were not being instantiated correctly. However,
it turned out that since this bug had been around for quite a bit,
many apps were relying on the broken behavior where the providers
would not be instantiated. To assist in the transition, the
`TestBed.deprecatedOverrideProvider` method was temporarily
introduced to mimic the old behavior so that apps would have a
longer time period to migrate their code.

2 years and 3 versions later, it is time to remove the temporary
method. This commit removes `TestBed.deprecatedOverrideProvider`
altogether. Any usages of `TestBed.deprecatedOverrideProvider`
should be replaced with `TestBed.overrideProvider`. This may mean
that providers that were not created before will now be instantiated,
which could mean that your tests need to provide more mocks or stubs
for the dependencies of the newly instantiated providers.
jasonaden pushed a commit that referenced this pull request May 21, 2019
…#30576)

BREAKING CHANGE

In PR #19558, we fixed a bug in `TestBed.overrideProvider` where
eager providers were not being instantiated correctly. However,
it turned out that since this bug had been around for quite a bit,
many apps were relying on the broken behavior where the providers
would not be instantiated. To assist in the transition, the
`TestBed.deprecatedOverrideProvider` method was temporarily
introduced to mimic the old behavior so that apps would have a
longer time period to migrate their code.

2 years and 3 versions later, it is time to remove the temporary
method. This commit removes `TestBed.deprecatedOverrideProvider`
altogether. Any usages of `TestBed.deprecatedOverrideProvider`
should be replaced with `TestBed.overrideProvider`. This may mean
that providers that were not created before will now be instantiated,
which could mean that your tests need to provide more mocks or stubs
for the dependencies of the newly instantiated providers.

PR Close #30576
jasonaden pushed a commit that referenced this pull request May 21, 2019
…#30576)

BREAKING CHANGE

In PR #19558, we fixed a bug in `TestBed.overrideProvider` where
eager providers were not being instantiated correctly. However,
it turned out that since this bug had been around for quite a bit,
many apps were relying on the broken behavior where the providers
would not be instantiated. To assist in the transition, the
`TestBed.deprecatedOverrideProvider` method was temporarily
introduced to mimic the old behavior so that apps would have a
longer time period to migrate their code.

2 years and 3 versions later, it is time to remove the temporary
method. This commit removes `TestBed.deprecatedOverrideProvider`
altogether. Any usages of `TestBed.deprecatedOverrideProvider`
should be replaced with `TestBed.overrideProvider`. This may mean
that providers that were not created before will now be instantiated,
which could mean that your tests need to provide more mocks or stubs
for the dependencies of the newly instantiated providers.

PR Close #30576
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 12, 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 area: core Issues related to the framework runtime cla: yes hotlist: google target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eager providers and Injector.get() can cause errors

4 participants