Skip to content

fix(runtime): retain shared providers across registration names - #5053

Merged
2heal1 merged 3 commits into
feat/mf-ssr-clear-cachefrom
fix/ssr-provider-alias-retention
Sep 11, 2026
Merged

2heal1 merged 3 commits into
feat/mf-ssr-clear-cachefrom
fix/ssr-provider-alias-retention

Conversation

@2heal1

@2heal1 2heal1 commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Description

A dynamic remote registered as dynamic can expose a container named v1. Removing it previously matched only the registration name against Shared.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 from format/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 _debugStack retaining 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 8e63776c predates #15614 and lacks __webpack_clear_exposed_cache__. GitHub CI still needs a published preview containing ce2c7515 or 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

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

@changeset-bot

changeset-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84c223e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 48 packages
Name Type
@module-federation/runtime-core Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/nextjs-mf Patch
@module-federation/runtime Patch
@module-federation/bridge-react Patch
@module-federation/enhanced Patch
@module-federation/esbuild Patch
@module-federation/runtime-tools Patch
@module-federation/devtools Patch
@module-federation/dts-plugin Patch
@module-federation/metro Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/node Patch
@module-federation/observability-plugin Patch
@module-federation/playground Patch
@module-federation/retry-plugin Patch
@module-federation/bridge-vue3 Patch
website-new Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/rstest Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/rspack Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
remote5 Patch
remote6 Patch
@module-federation/cli Patch
create-module-federation Patch
@module-federation/error-codes Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/sdk Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/treeshake-frontend Patch
@module-federation/treeshake-server Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/bridge-shared Patch
@module-federation/utilities Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-10T12:27:55.702008Z c4d9417 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/@module-federation/devtools@0d76e32

@module-federation/cli

pnpm add https://pkg.pr.new/@module-federation/cli@0d76e32

create-module-federation

pnpm add https://pkg.pr.new/create-module-federation@0d76e32

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/@module-federation/dts-plugin@0d76e32

@module-federation/enhanced

pnpm add https://pkg.pr.new/@module-federation/enhanced@0d76e32

@module-federation/error-codes

pnpm add https://pkg.pr.new/@module-federation/error-codes@0d76e32

@module-federation/esbuild

pnpm add https://pkg.pr.new/@module-federation/esbuild@0d76e32

@module-federation/managers

pnpm add https://pkg.pr.new/@module-federation/managers@0d76e32

@module-federation/manifest

pnpm add https://pkg.pr.new/@module-federation/manifest@0d76e32

@module-federation/metro

pnpm add https://pkg.pr.new/@module-federation/metro@0d76e32

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnc-cli@0d76e32

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rnef@0d76e32

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/@module-federation/metro-plugin-rock@0d76e32

@module-federation/modern-js

pnpm add https://pkg.pr.new/@module-federation/modern-js@0d76e32

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/@module-federation/modern-js-v3@0d76e32

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/@module-federation/native-federation-tests@0d76e32

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/@module-federation/native-federation-typescript@0d76e32

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/@module-federation/nextjs-mf@0d76e32

@module-federation/node

pnpm add https://pkg.pr.new/@module-federation/node@0d76e32

@module-federation/observability-plugin

pnpm add https://pkg.pr.new/@module-federation/observability-plugin@0d76e32

@module-federation/playground

pnpm add https://pkg.pr.new/@module-federation/playground@0d76e32

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/@module-federation/retry-plugin@0d76e32

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/@module-federation/rsbuild-plugin@0d76e32

@module-federation/rspack

pnpm add https://pkg.pr.new/@module-federation/rspack@0d76e32

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/@module-federation/rspress-plugin@0d76e32

@module-federation/rstest

pnpm add https://pkg.pr.new/@module-federation/rstest@0d76e32

@module-federation/runtime

pnpm add https://pkg.pr.new/@module-federation/runtime@0d76e32

@module-federation/runtime-core

pnpm add https://pkg.pr.new/@module-federation/runtime-core@0d76e32

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/@module-federation/runtime-tools@0d76e32

@module-federation/sdk

pnpm add https://pkg.pr.new/@module-federation/sdk@0d76e32

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/@module-federation/storybook-addon@0d76e32

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/@module-federation/third-party-dts-extractor@0d76e32

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/@module-federation/treeshake-frontend@0d76e32

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/@module-federation/treeshake-server@0d76e32

@module-federation/typescript

pnpm add https://pkg.pr.new/@module-federation/typescript@0d76e32

@module-federation/utilities

pnpm add https://pkg.pr.new/@module-federation/utilities@0d76e32

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/@module-federation/webpack-bundler-runtime@0d76e32

@module-federation/bridge-react

pnpm add https://pkg.pr.new/@module-federation/bridge-react@0d76e32

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/@module-federation/bridge-react-webpack-plugin@0d76e32

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/@module-federation/bridge-shared@0d76e32

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/@module-federation/bridge-vue3@0d76e32

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/@module-federation/inject-external-runtime-core-plugin@0d76e32

commit: 0d76e32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +791 to +793
const providerNames = new Set(
[remoteInfo.name, remoteInfo.entryGlobalName].filter(Boolean),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +425 to +427
for (const remote of toList(instance?.options?.remotes)) {
if (remoteNames.includes(remote.name))
remoteInfos.push(createBundlerRemoteInfo(remote));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@2heal1
2heal1 merged commit 97ef36f into feat/mf-ssr-clear-cache Sep 11, 2026
17 of 18 checks passed
@2heal1
2heal1 deleted the fix/ssr-provider-alias-retention branch September 11, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant