fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationCon…#4470
fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationCon…#44702heal1 merged 4 commits intomodule-federation:mainfrom
Conversation
…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 detectedLatest commit: cbdddfc The changes in this PR will be included in the next version bump. This PR includes changesets to release 43 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 |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@codex review pr |
There was a problem hiding this comment.
💡 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 []; |
There was a problem hiding this comment.
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 👍 / 👎.
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/data-prefetch
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/modern-js-v3
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@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: |
Bundle Size Report1 package(s) changed, 40 unchanged.
Total dist: 6.89 MB (+448 B (+0.0%)) |
…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:
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.
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
Checklist