Skip to content

fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationCon…#4470

Merged
2heal1 merged 4 commits intomodule-federation:mainfrom
sschwenker-im:fix-issue-4469
Feb 25, 2026
Merged

fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationCon…#4470
2heal1 merged 4 commits intomodule-federation:mainfrom
sschwenker-im:fix-issue-4469

Conversation

@sschwenker-im
Copy link
Copy Markdown
Contributor

@sschwenker-im sschwenker-im commented Feb 23, 2026

…fig validation

fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationConfig validation

Fixes two bugs in forkDevWorker.ts that caused the DTS worker to crash after successfully generating types:

  1. Bug: getLocalRemoteNames passes host object directly to retrieveHostConfig, which expects options.moduleFederationConfig. Fix: Wrap retrieveHostConfig call in try-catch, return empty array on validation failure and log warning.

  2. Bug: process.on('message') EXIT handler calls moduleServer.exit() without null check, causing TypeError when moduleServer is undefined. Fix: Use optional chaining (moduleServer?.exit()) for consistency with other moduleServer accesses in the file.

These crashes occurred when consumeTypes was disabled and the worker received an EXIT message before moduleServer initialization completed.

Description

Related Issue

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.

…fig validation

fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationConfig validation

Fixes two bugs in forkDevWorker.ts that caused the DTS worker to crash
after successfully generating types:

1. Bug: getLocalRemoteNames passes host object directly to
   retrieveHostConfig, which expects options.moduleFederationConfig.
   Fix: Wrap retrieveHostConfig call in try-catch, return empty array
   on validation failure and log warning.

2. Bug: process.on('message') EXIT handler calls moduleServer.exit()
   without null check, causing TypeError when moduleServer is undefined.
   Fix: Use optional chaining (moduleServer?.exit()) for consistency
   with other moduleServer accesses in the file.

These crashes occurred when consumeTypes was disabled and the worker
received an EXIT message before moduleServer initialization completed.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: cbdddfc

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

This PR includes changesets to release 43 packages
Name Type
@module-federation/dts-plugin Patch
@module-federation/cli Patch
@module-federation/enhanced Patch
@module-federation/manifest Patch
@module-federation/rspack Patch
@module-federation/modern-js-v3 Patch
@module-federation/modern-js Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/rsbuild-plugin Patch
@module-federation/rspress-plugin Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
remote5 Patch
remote6 Patch
website-new Patch
@module-federation/runtime Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/retry-plugin Patch
@module-federation/data-prefetch Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/metro Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/esbuild 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

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 23, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit cbdddfc
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/699e6561ab17ef00080b082c
😎 Deploy Preview https://deploy-preview-4470--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ScriptedAlchemy
Copy link
Copy Markdown
Member

@codex review pr

Copy link
Copy Markdown

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

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: cbdddfce1d

ℹ️ 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".

'forkDevWorker',
'warn',
);
return [];
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 Don't silently drop remotes on host-config errors

getLocalRemoteNames now catches any retrieveHostConfig failure and returns an empty remote list, so real host-config/parsing errors no longer fail fast and the dev server starts with no remotes. In normal runs this is effectively silent because fileLog only emits when FEDERATION_DEBUG is set (packages/dts-plugin/src/server/utils/log.ts:13), which means remote type sync/live-reload can stop working without actionable feedback; this should either rethrow non-expected errors or use an always-on warning path.

Useful? React with 👍 / 👎.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 25, 2026

Open in StackBlitz

@module-federation/devtools

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

@module-federation/cli

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

create-module-federation

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

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/data-prefetch@cbdddfc

@module-federation/dts-plugin

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

@module-federation/enhanced

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

@module-federation/error-codes

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

@module-federation/managers

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

@module-federation/manifest

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

@module-federation/metro

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

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

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

@module-federation/metro-plugin-rnef

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

@module-federation/modern-js-v3

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

@module-federation/retry-plugin

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

@module-federation/rsbuild-plugin

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

@module-federation/rspack

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

@module-federation/rspress-plugin

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

@module-federation/runtime

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

@module-federation/runtime-core

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

@module-federation/runtime-tools

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

@module-federation/sdk

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

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

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

@module-federation/treeshake-frontend

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

@module-federation/treeshake-server

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

@module-federation/webpack-bundler-runtime

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

@module-federation/bridge-react

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

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

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

@module-federation/bridge-shared

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

@module-federation/bridge-vue3

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

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

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

commit: cbdddfc

@github-actions
Copy link
Copy Markdown
Contributor

Bundle Size Report

1 package(s) changed, 40 unchanged.

Package Total dist Delta ESM gzip Delta
dts-plugin 627.1 kB +448 B (+0.1%) 23.4 kB no change

Total dist: 6.89 MB (+448 B (+0.0%))
Total ESM gzip: 138.6 kB (no change)

@2heal1 2heal1 merged commit 5954fe7 into module-federation:main Feb 25, 2026
22 checks passed
@2heal1 2heal1 mentioned this pull request Mar 5, 2026
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.

3 participants