diff options
author | 2021-11-22 07:47:14 -0600 | |
---|---|---|
committer | 2021-11-22 08:47:14 -0500 | |
commit | 8775730eb984851cb397f4d5de3fe3427e9d844c (patch) | |
tree | ae2c125b410a43d0025fee446f13bcd834c97d94 | |
parent | 902405f4a3300ff5f1d19f89e46fcafe33e89192 (diff) | |
download | astro-8775730eb984851cb397f4d5de3fe3427e9d844c.tar.gz astro-8775730eb984851cb397f4d5de3fe3427e9d844c.tar.zst astro-8775730eb984851cb397f4d5de3fe3427e9d844c.zip |
fix: avoid infinite loops in crawlCSS (#1956)
-rw-r--r-- | .changeset/six-rockets-jump.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/ssr/css.ts | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/.changeset/six-rockets-jump.md b/.changeset/six-rockets-jump.md new file mode 100644 index 000000000..c03f87c49 --- /dev/null +++ b/.changeset/six-rockets-jump.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix CSS scanning bug that could lead to infinite loops diff --git a/packages/astro/src/core/ssr/css.ts b/packages/astro/src/core/ssr/css.ts index 550af10b7..15898cdab 100644 --- a/packages/astro/src/core/ssr/css.ts +++ b/packages/astro/src/core/ssr/css.ts @@ -18,6 +18,9 @@ export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer): function crawlCSS(entryModule: string, scanned = new Set<string>()) { const moduleName = idToModuleMap.get(entryModule); if (!moduleName) return; + if (!moduleName.id) return; + // mark the entrypoint as scanned to avoid an infinite loop + scanned.add(moduleName.id) for (const importedModule of moduleName.importedModules) { if (!importedModule.id || scanned.has(importedModule.id)) continue; const ext = path.extname(importedModule.id.toLowerCase()); |