fix(core): fix race condition in class dependency resolution from imported modules #15504
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix race condition in class dependency resolution, which could otherwise lead to undefined or null injection. This is a followup to #15405 that fixes another case of this bug that was not taken care of in the previous PR. In this case specifically, the staticity of the dependency tree could be checked before all dependencies are loaded and the param / property Barrier is passed, resulting in a potentially wrong evaluation of the
isTreeStaticproperty of theInstanceWrapper.Closes #4873
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
A specific setup of transient-scoped and request-scoped providers with many global modules leads to
nullorundefinedinjection due to incorrect evaluation of the staticity of the dependency tree with a specific setup of request-scoped and transient-scoped providers with many global modules.Issue Number: #4873
What is the new behavior?
The dependencies are injected correctly.
Does this PR introduce a breaking change?
Other information
I removed 2 test cases that test whether
loadProvider()was called, becauselookupComponentInImports()no longer calls it. To catch future regressions, I extended an existing integration test introduced in my previous PR regarding this issue (#15405).The fix lies in the removal of a
loadProvider()call, which is safe, because it is called almost immediately (along with the appropriate settlement signal) after the method returns and the param / property Barrier is passed (viaresolveComponentHost()).