Repository navigation
fix(runtime): preserve shared identity while invalidating host consumers - #5049
Conversation
🦋 Changeset detectedLatest commit: 8bc7b9b 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 |
@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: |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bc7b9b0fa
ℹ️ 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".
| shareVersion, | ||
| ]); | ||
| } | ||
| if (shared.useIn.length || shared.loading) { |
There was a problem hiding this comment.
Do not retain providers for already-settled share loads
When a provider has loaded a shared module but has no external consumers, SharedHandler.loadShare sets loaded = true but leaves the resolved promise in shared.loading. Consequently, after this code removes the provider itself from useIn, shared.loading remains truthy and permanently sets preserveRemoteRuntime, retaining the removed provider's global and execution cache. This regresses cleanup for self-consumed shares; only an unsettled load (for example, shared.loading && !shared.loaded) should trigger this retention.
Useful? React with 👍 / 👎.
Description
Remote removal previously either skipped host invalidation when a provider supplied shared modules, or cleared the provider execution cache and recreated its singleton. This patch invalidates host remote/consumer caches independently while retaining provider caches needed by external shared consumers or pending shared loads. Runtime-core now checks shared ownership even after the provider leaves the instance registry.
Tests cover host eviction, loaded/loading shares, absent provider registration, and strict shared/lazy dependency identity in real Rspack artifacts. Existing undefined
vi.fnusages in the touched runtime-core tests were corrected to importedrs.fn. Adds patch changesets for runtime-core and webpack-bundler-runtime.Draft: R1 remains incomplete. Conservative provider retention prevents collection of unrelated provider payload. Modern SSR CI fails
remove-remote-shared-cache.cy.js:40(nonSharedPayloadCollectedis false); this assertion is unchanged. Selective provider cleanup is required before the production memory requirement can pass. Parent metadata and adapter disposal are also still open.Validation: builds passed; runtime-core 134/134 and bundler-runtime 109/109 tests passed. Local Rspack + Modern artifacts: 8 pass / 5 TODO; installed canary: 7 pass / 5 TODO / 1 explicit Modern skip. Two shared TODOs are now passing regressions. Modern remote-cache E2E passed in this run, shared-cache E2E failed as above. Changed files pass formatting; full-repo format still reports 683 existing/generated files. Changeset scope/status passed. Exact commands and skipped coverage are recorded in tools/ssr-cache/VALIDATION.md. No claim of production readiness or full provider GC.
Related Issue
Continues the R0 baseline merged in #5048. No separate issue linked.
Types of changes
Checklist