Skip to content

Commit fb30dc0

Browse files
gatsbybotpieh
andauthored
fix(gatsby): handle cyclic chunkgroup children (#38052) (#38061)
(cherry picked from commit 272dacd) Co-authored-by: Michal Piechowiak <[email protected]>
1 parent ae5a654 commit fb30dc0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/gatsby/src/utils/webpack/get-ssr-chunk-hashes.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ type ChunkGroup = webpack.Compilation["chunkGroups"][0]
66
function getHashes(
77
chunkGroup: ChunkGroup,
88
compilation: webpack.Compilation,
9-
hashes: Array<string> = []
9+
hashes: Array<string> = [],
10+
visitedChunkGroups: Set<ChunkGroup> = new Set()
1011
): Array<string> {
12+
if (visitedChunkGroups.has(chunkGroup)) {
13+
return hashes
14+
}
15+
visitedChunkGroups.add(chunkGroup)
16+
1117
for (const chunk of chunkGroup.chunks) {
1218
if (!chunk.hash) {
1319
throw new Error(
@@ -23,7 +29,7 @@ function getHashes(
2329
)
2430

2531
if (isNotImportedByAsyncRequires) {
26-
getHashes(childChunkGroup, compilation, hashes)
32+
getHashes(childChunkGroup, compilation, hashes, visitedChunkGroups)
2733
}
2834
}
2935

0 commit comments

Comments
 (0)