fix(webpack-bundler-runtime): preserve share scopes on repeated container init - #4969
fix(webpack-bundler-runtime): preserve share scopes on repeated container init#4969BaurinVladislav wants to merge 1 commit into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
🦋 Changeset detectedLatest commit: dd53c7a The changes in this PR will be included in the next version bump. This PR includes changesets to release 47 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@ScriptedAlchemy — fixes #4691 where repeated remote container init with an incomplete |
|
Gentle nudge — we're waiting on this fix to land before we can roll it out across several production repositories. Would really appreciate a review when you have a moment. Happy to adjust anything needed. |
…iner init resolveShareScope now falls back to the federation instance's existing shareScopeMap when the incoming host scope is missing or empty. initShareScopeMap merges incoming scopes with existing ones instead of replacing them, providing defense-in-depth against incomplete re-initialization data. Fixes module-federation#4691
9c11143 to
dd53c7a
Compare
|
@2heal1 @ScriptedAlchemy — could you please review when you have a moment? This builds on #4698: fixes repeated container init wiping non-default share scopes. All tests green (103 + 96 + 96), ESLint clean. Rebased on latest main. |
|
@ryok90 |
Description
Fixes #4691 — repeated dynamic remote container init can lose non-default share scopes.
Root cause
When a host re-initializes a remote container with an incomplete
shareScopeMap(empty, truncated, or missing non-default scope keys), the previous code would:hostShareScopeMaptoinitShareScopeMapinitShareScopeMapwould replace (not merge) the existing scope, wiping previously registered shared packagesThis caused shared singletons to resolve different runtime instances across remotes, leading to crashes like
No QueryClient set.Fix
Two-level defense:
initContainerEntry.ts—resolveShareScopewith clear precedence: non-empty host scope > existing federation scope > fallback. When the re-init provides an empty or missing scope entry, the existing scope from the federation instance is used instead.runtime-core—initShareScopeMapnow merges incoming scopes with existing ones ({...existing, ...incoming}) instead of replacing. This provides defense-in-depth in caseresolveShareScopeis bypassed or the same pattern appears in other callers.Changes
webpack-bundler-runtime/src/initContainerEntry.tsresolveShareScopewith fallback toexistingShareScopeMapruntime-core/src/shared/index.tsinitShareScopeMapruntime-core/src/shared/disabled.tsDisabledSharedHandlerwebpack-bundler-runtime/__tests__/initContainerEntry.array.spec.tswebpack-bundler-runtime/__tests__/initContainerEntry.non-array.spec.tsshareScopeKeypathruntime/__tests__/shares.spec.tsinitShareScopeMapValidation
Notes
change: fixlabel needed (no permissions on upstream)Related Issue
Closes #4691
Types of changes