Skip to content

fix(runtime-core): keep shared modules available when remotes fail - #5138

Open
tonoizer wants to merge 3 commits into
module-federation:mainfrom
tonoizer:fix/runtime-core-share-startup-failures
Open

tonoizer wants to merge 3 commits into
module-federation:mainfrom
tonoizer:fix/runtime-core-share-startup-failures

Conversation

@tonoizer

@tonoizer tonoizer commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With shareStrategy: 'version-first', a failed remote manifest resolves before the existing error handler, while a failed container init() throws from finally. Either failure rejects loadShare() even when the host provides the requested shared package.

Move remote resolution and entry loading into the same guarded path, report failures through errorLoadRemote with beforeLoadShare, and skip failed remotes during share negotiation. The manifest is not replaced or cached, so a later loadRemote() can retry and recover. The existing loadShare resource context is retained. This runtime-core fix applies across bundlers, and a patch changeset is included.

Independent review found that a container could register a higher shared version and then throw during init(). The failed version would remain selectable despite the caught error. Initialization now tracks share-scope assignments and rolls back a failed remote's writes while preserving preexisting shares and writes from concurrent healthy remotes.

Validation

  • corepack pnpm exec turbo run build --filter=@module-federation/runtime-core passed.
  • corepack pnpm --filter @module-federation/runtime-core exec rstest run --include '**/*.spec.ts' passed (131 tests).
  • PowerShell ESLint equivalent of the runtime-core package lint script passed: $env:ESLINT_USE_FLAT_CONFIG='false'; corepack pnpm --filter @module-federation/runtime-core exec eslint --ignore-pattern node_modules '**/*.ts' package.json.
  • Targeted Prettier check on all six changed files passed.
  • The new tests cover host share fallback, beforeLoadShare hook arguments, no cached replacement manifest, later remote recovery, failed init after partial registration, restoration of a prior share, and concurrent healthy and failing inits.

Checks and limits

  • corepack pnpm exec prettier --check . reports existing formatting issues outside this change. The changed files pass the targeted check.
  • corepack pnpm exec changeset status cannot complete because the repository's @changesets/assemble-release-plan build references a missing ./apply-links.ts. The changeset was parsed separately and contains one @module-federation/runtime-core patch release.
  • Full workspace CI was not run; this change is confined to runtime-core.
  • Rollback tracks normal share-scope assignments. Custom containers that use read-only, non-configurable scope properties or mutate shared entries through property descriptors or in place are outside the covered path.

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e675608

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/nextjs-mf Patch
@module-federation/runtime Patch
@module-federation/bridge-react Patch
@module-federation/devtools Patch
@module-federation/dts-plugin Patch
@module-federation/esbuild 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/runtime-tools Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/bridge-vue3 Patch
website-new 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
@module-federation/rsbuild-plugin Patch
@module-federation/rstest Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/rspress-plugin Patch
remote5 Patch
remote6 Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider 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

@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/esbuild

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/metro-plugin-rock

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

@module-federation/modern-js

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

@module-federation/modern-js-v3

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

@module-federation/native-federation-tests

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

@module-federation/native-federation-typescript

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

@module-federation/nextjs-mf

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

@module-federation/node

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

@module-federation/observability-plugin

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

@module-federation/playground

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/rstest

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

@module-federation/storybook-addon

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/typescript

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

@module-federation/utilities

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: e6f9709

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Report

12 package(s) changed, 31 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/bridge-react 311.2 kB +62 B (+0.0%) 1.5 kB +1 B (+0.1%)
@module-federation/bridge-vue3 195.2 kB +3.5 kB (+1.8%) 28.0 kB +595 B (+2.1%)
@module-federation/dts-plugin 335.7 kB +31 B (+0.0%) 4.7 kB no change
@module-federation/inject-external-runtime-core-plugin 5.2 kB -26 B (-0.5%) 519 B no change
@module-federation/playground 16.09 MB +8.5 kB (+0.1%) 45.8 kB +9 B (+0.0%)
@module-federation/runtime-core 316.2 kB +5.7 kB (+1.8%) 570 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/bridge-vue3 20.4 kB +398 B (+1.9%) 20.6 kB +409 B (+2.0%)
@module-federation/cli 2.3 kB -3 B (-0.1%) 2.4 kB -31 B (-1.3%)
@module-federation/core 1.0 kB -2 B (-0.2%) 1.0 kB -32 B (-2.9%)
@module-federation/devtools 30.3 kB -5 B (-0.0%) 30.3 kB -28 B (-0.1%)
@module-federation/enhanced 2.7 kB +5 B (+0.2%) 2.8 kB -42 B (-1.5%)
@module-federation/metro-plugin-rnc-cli 416 B +2 B (+0.5%) 435 B -24 B (-5.2%)
@module-federation/node 9.1 kB -1 B (-0.0%) 9.2 kB -28 B (-0.3%)
@module-federation/playground 41.7 kB +13 B (+0.0%) 41.7 kB +13 B (+0.0%)
@module-federation/runtime-core 16.6 kB +423 B (+2.6%) 16.2 kB +422 B (+2.6%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 22.7 kB +404 B (+1.8%) 24.2 kB +414 B (+1.7%) +1.6 kB +10 B

Total dist (raw): 23.42 MB (+17.8 kB (+0.1%))
Total ESM gzip: 112.3 kB (+605 B (+0.5%))
Total web bundle (gzip): 254.2 kB (+830 B (+0.3%))
Total node bundle (gzip): 256.4 kB (+659 B (+0.3%))
Tracked ./bundler entry gzip: 563 B (no change)
Tracked ./bundler web bundle (gzip): 4.9 kB (no change)
Tracked ./bundler node bundle (gzip): 4.9 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

This branch has not been deployed

No deployments
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.

2 participants