Skip to content

Commit 5954fe7

Browse files
fix(dts-plugin): prevent fork-dev-worker crash on moduleFederationCon… (#4470)
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
1 parent 03dab5a commit 5954fe7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.changeset/pretty-clowns-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/dts-plugin': patch
3+
---
4+
5+
Fix fork-dev-worker crashes in dts-plugin when consumeTypes is disabled

packages/dts-plugin/src/dev-worker/forkDevWorker.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ function getLocalRemoteNames(
4040
if (!options) {
4141
return [];
4242
}
43-
const { mapRemotesToDownload } = retrieveHostConfig(options);
43+
let hostConfig;
44+
try {
45+
hostConfig = retrieveHostConfig(options);
46+
} catch (e) {
47+
fileLog(
48+
`getLocalRemoteNames: retrieveHostConfig failed: ${(e as Error).message}`,
49+
'forkDevWorker',
50+
'warn',
51+
);
52+
return [];
53+
}
54+
const { mapRemotesToDownload } = hostConfig;
4455

4556
return Object.keys(mapRemotesToDownload).reduce<Remote[]>(
4657
(sum, remoteModuleName) => {
@@ -189,7 +200,7 @@ process.on('message', (message: rpc.RpcMessage) => {
189200
'forkDevWorker',
190201
'error',
191202
);
192-
moduleServer.exit();
203+
moduleServer?.exit();
193204
process.exit(0);
194205
}
195206
});

0 commit comments

Comments
 (0)