Skip to content

Commit d0bb83f

Browse files
committed
fix: remove chunks from installedChunks on fail to enable retries
1 parent 39d7271 commit d0bb83f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/node/src/runtimePlugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,15 @@ export const installChunk = (
235235
}
236236
};
237237

238+
// Hoisted utility function to remove a chunk on fail
239+
export const deleteChunk = (
240+
chunkId: string,
241+
installedChunks: { [key: string]: any },
242+
): boolean => {
243+
delete installedChunks[chunkId];
244+
return true;
245+
}
246+
238247
// Hoisted function to set up webpack script loader
239248
export const setupScriptLoader = (): void => {
240249
__webpack_require__.l = (
@@ -297,7 +306,7 @@ export const setupChunkHandler = (
297306
chunkId,
298307
__webpack_require__.federation.rootOutputDir || '',
299308
(err, chunk) => {
300-
if (err) return reject(err);
309+
if (err) return deleteChunk(chunkId, installedChunks) && reject(err);
301310
if (chunk) installChunk(chunk, installedChunks);
302311
resolve(chunk);
303312
},
@@ -312,7 +321,7 @@ export const setupChunkHandler = (
312321
chunkName,
313322
__webpack_require__.federation.initOptions.name,
314323
(err, chunk) => {
315-
if (err) return reject(err);
324+
if (err) return deleteChunk(chunkId, installedChunks) && reject(err);
316325
if (chunk) installChunk(chunk, installedChunks);
317326
resolve(chunk);
318327
},

0 commit comments

Comments
 (0)