Skip to content

Commit d4680a0

Browse files
authored
fix: prevent loops in postbuild analysis phase (#14450)
It is currently possible for a chunk to import chunks that import itself. I'm not exactly sure where this occurs or why as I can't reproduce it in a simple repository, but a simple fix is to prevent importing already visited chunks. Helps with #14444 though doesn't fix the underlying issue
1 parent 1464d20 commit d4680a0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.changeset/curvy-icons-fall.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: prevent loops in postbuild analysis phase

packages/kit/src/core/postbuild/analyse.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,12 @@ function list_features(route, manifest_data, server_manifest, tracked_features)
255255
manifest_data.routes.find((r) => r.id === route.id)
256256
);
257257

258+
const visited = new Set();
258259
/** @param {string} id */
259260
function visit(id) {
261+
if (visited.has(id)) return;
262+
visited.add(id);
263+
260264
const chunk = server_manifest[id];
261265
if (!chunk) return;
262266

0 commit comments

Comments
 (0)