Skip to content

Commit

Permalink
fix(perf): do not await in for loop to enqueue asset transforms. F…
Browse files Browse the repository at this point in the history
…ixes #12845
  • Loading branch information
adamchal committed Jan 7, 2025
1 parent 8b9d530 commit 3959913
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/new-radios-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': patch
---

Improve static asset generation performance by removing the `await` in the `for` loop. This change will allow the p-queue concurrency to limit the number of parallel tasks. Previously, the `await` in the `for` loop would cause all asset generation tasks to run serially.

Fixes #12845
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function generatePages(options: StaticBuildOptions, internals: Buil

const assetsTimer = performance.now();
for (const [originalPath, transforms] of staticImageList) {
await generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
generateImagesForPath(originalPath, transforms, assetsCreationPipeline, queue);
}

await queue.onIdle();
Expand Down

0 comments on commit 3959913

Please sign in to comment.