Repository navigation
fix(runtime): dispose and rebind bundler cache adapters - #5052
Conversation
🦋 Changeset detectedLatest commit: f087e15 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: f087e15de1
ℹ️ 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 targets = bindings.map((binding) => ({ | ||
| binding, | ||
| target: getClearTarget({ name: remote.name, webpackRequire: binding }), | ||
| })); |
There was a problem hiding this comment.
Skip bindings without bundler remote mappings
When a reused MF instance has an attached webpack runtime whose compilation emitted no remote runtime, its optional bundlerRuntimeOptions.remotes is undefined. This new all-bindings map still includes that runtime, and captureBundlerRemoteInfoSnapshot subsequently dereferences remotesOptions.idToRemoteMap, causing force registration from another valid binding to reject and roll back. Skip bindings without mapping tables, since they have no bundler mappings to update or clear.
Useful? React with 👍 / 👎.
Description
After an application rebuild reused its MF instance, the removal plugin still called the first bundler and installation stacked instance wrappers/listeners. Make the plugin query live bindings from the instance and return an idempotent disposer from
installClearCache, also available asfederation.disposeClearCache.A shared per-instance registry coordinates multiple bundlers and separately bundled copies. The last detach restores owned methods and removes its listener, preserves later third-party wrappers, and releases captured runtime references. Pending cache cleanup prevents detachment; saved clear functions reject after disposal. Remove/force-registration cleanup reaches all live bindings and waits for their outcomes. The unused moduleCache.set generation wrapper is removed.
The application owner must drain work before disposal. This is an adapter primitive, not Modern admission/drain or full application GC. Persistent MF/shared/business references can still retain code.
Validation: runtime-tools build 6/6; complete bundler package 116/116 tests; strict real Rspack + Modern HTTP artifact baseline 23/23, zero TODOs/skips, including the three previously stale-adapter cases and a retained-handle WeakRef check. Full Modern SSR CI passes both remote-cache and shared-cache/GC specs. Existing intermittent capture failure did not reproduce and is not claimed fixed. Changed-file formatting, diff checks and changeset planning pass; full-repo Prettier still reports 683 pre-existing/generated files. Unchanged runtime-core/native Rspack suites and unrelated CI jobs were not rerun. Exact commands and limits: tools/ssr-cache/VALIDATION.md. No publication.
Related Issue
Continues merged #5051 and the SSR cache RFC R1 adapter lifecycle work.
Types of changes
Checklist