fix(modules): Immediately resolve follow-up dyn imports to a dyn imported module #14958
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.
When a dynamically imported module gets resolved, any code that comes after an
await import()
to that module will continue running. However, if that is the last code in the evaluation of another dynamically imported module, that second module will not resolve until the next iteration of the event loop, even though it does not depend on the event loop at all.When the event loop is being blocked by a long-running operation, such as a long-running timer, or by an async op that might never end, such as with workers or
BroadcastChannel
s, that will result in the second dynamically imported module not being resolved for a while, or ever.This change fixes this by running the dynamic module loading steps in a loop until no more dynamic modules can be resolved.
Fixes #14726.
This change might regress performance. We should run the benchmarks to make sure it doesn't regress them significantly.