Repository navigation
fix(runtime): retain shared providers across registration names - #5053
Conversation
🦋 Changeset detectedLatest commit: 84c223e The changes in this PR will be included in the next version bump. This PR includes changesets to release 48 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/playground
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/rstest
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4d9417714
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const providerNames = new Set( | ||
| [remoteInfo.name, remoteInfo.entryGlobalName].filter(Boolean), | ||
| ); |
There was a problem hiding this comment.
Preserve the manifest's provider name
When a manifest remote is registered as dynamic, declares its federation name as v1, and uses a distinct metaData.globalName such as __FEDERATION_v1:custom__, this set contains only dynamic and the encoded global name. assignRemoteInfo() does not copy the manifest name, while SharedHandler.registerShared() sets Shared.from to the provider's federation name (v1), so neither cleanup layer recognizes the live share and the provider execution cache is fully cleared, recreating the singleton this change intends to retain. Carry the manifest/container name into the ownership metadata rather than assuming it equals the entry global.
Useful? React with 👍 / 👎.
| for (const remote of toList(instance?.options?.remotes)) { | ||
| if (remoteNames.includes(remote.name)) | ||
| remoteInfos.push(createBundlerRemoteInfo(remote)); |
There was a problem hiding this comment.
Do not treat registration names as remote-entry globals
For a runtime-registered manifest remote whose registration name is dynamic but whose resolved entry global is different, the synthesized info added here still has name: 'dynamic'. getRemoteEntryGlobalKeys() unconditionally includes that name, and cleanupRemoteEntryCache() consequently deletes an own globalThis.dynamic property even though it is not the remote container; this can corrupt unrelated application or runtime state whenever such a global exists. Runtime registration names should remain cache lookup keys, while only known entry-global names should be eligible for global deletion.
Useful? React with 👍 / 👎.
Description
A dynamic remote registered as
dynamiccan expose a container namedv1. Removing it previously matched only the registration name againstShared.from, allowing live shared factories to lose their execution caches. The bundler hook also lacked compiler remoteInfos for dynamic registrations. A real Modern application rebuild exposed this even though the older cached-host baseline passed.Resolve provider ownership from configured and loaded runtime metadata as well as container global names in both cleanup layers. Keep registration names for host-module invalidation and provider names for shared retention. Tests cover compiler/runtime registrations, loading shares and already-detached providers. No shared
fromformat/API migration or Rspack source change is included.Validation: runtime-core 138/138; bundler runtime 122/122; runtime-tools dependency build 6/6; strict local Rspack 2.2.2 + Modern baseline 13/13. The companion Modern production test now passes dynamic v1/v2/v3, strict host/provider shared identity, adapter disposal and failed-generation recovery. Changed-file formatting, changeset scope/planning and diff checks pass. Full-repo Prettier still reports 683 existing/generated or unrelated user-dirty files; these were left untouched. The Modern SSR Cypress job was subsequently reproduced and investigated: eager host compilation prevents probe state resets, and the shared-provider fixture uses production dependencies to avoid React development
_debugStackretaining the exposed payload. The final clean-start run using the matching local Rspack build passes both Cypress specs (2/2, no skips). The original cache and GC assertions remain intact. Long-running memory endurance remains deferred to RFC R6. Exact commands:tools/ssr-cache/README.md.The locked Rspack preview
8e63776cpredates #15614 and lacks__webpack_clear_exposed_cache__. GitHub CI still needs a published preview containingce2c7515or a descendant and the corresponding lockfile update. No legacy-provider fallback or skipped assertion is introduced.Related Issue
Continues #5052 and the SSR cache RFC.
Companion Modern R3 #8862 contains the strict production regression.
Target:
feat/mf-ssr-clear-cache.Types of changes
Checklist