Skip to content

Commit

Permalink
fix[astro]: correct endless route matching loop (#3709)
Browse files Browse the repository at this point in the history
* fix: correct endless route matching loop
resolve #3707

* chore: add changeset
  • Loading branch information
bayssmekanique committed Mar 14, 2024
1 parent efd1506 commit 8e80d61
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/moody-pigs-bake.md
@@ -0,0 +1,5 @@
---
"sst": patch
---

Astro: fixes infinite loop during deployment caused by Astro plugins
6 changes: 5 additions & 1 deletion packages/sst/src/constructs/util/astroRouteCompressor.ts
Expand Up @@ -38,7 +38,11 @@ function buildRouteTree(routes: BuildMetaConfig["routes"], level = 0) {
) {
delete routeTree.branches[key];
} else if (branch.nodes.length > 1) {
routeTree.branches[key] = buildRouteTree(branch.nodes, level + 1);
const deduplicatedNodes = branch.nodes.filter(
(node, index, arr) =>
arr.findIndex((n) => n.pattern === node.pattern) === index
);
routeTree.branches[key] = buildRouteTree(deduplicatedNodes, level + 1);
branch.nodes = [];
}
}
Expand Down

0 comments on commit 8e80d61

Please sign in to comment.