From ee63074ccac1363118e090bfa5072943e030750d Mon Sep 17 00:00:00 2001 From: Reuben Tier Date: Sun, 6 Apr 2025 14:15:49 +0100 Subject: [PATCH] Fix build errors being ignored when using concurrency --- .changeset/wide-adults-smell.md | 5 ++++ packages/astro/src/core/build/generate.ts | 2 +- packages/astro/test/build-concurrency.test.js | 29 +++++++++++++++++++ .../fixtures/build-concurrency/package.json | 8 +++++ .../build-concurrency/src/pages/index.astro | 5 ++++ .../build-concurrency/src/pages/page2.astro | 4 +++ pnpm-lock.yaml | 7 ++++- 7 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .changeset/wide-adults-smell.md create mode 100644 packages/astro/test/build-concurrency.test.js create mode 100644 packages/astro/test/fixtures/build-concurrency/package.json create mode 100644 packages/astro/test/fixtures/build-concurrency/src/pages/index.astro create mode 100644 packages/astro/test/fixtures/build-concurrency/src/pages/page2.astro diff --git a/.changeset/wide-adults-smell.md b/.changeset/wide-adults-smell.md new file mode 100644 index 000000000000..d370bdc4f780 --- /dev/null +++ b/.changeset/wide-adults-smell.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix build errors being ignored when build.concurrency > 1 diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index f612ec7fa075..6514fedc02d1 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -297,7 +297,7 @@ async function generatePage( const path = paths[i]; promises.push(limit(() => generatePathWithLogs(path, route, i, paths, true))); } - await Promise.allSettled(promises); + await Promise.all(promises); } else { for (let i = 0; i < paths.length; i++) { const path = paths[i]; diff --git a/packages/astro/test/build-concurrency.test.js b/packages/astro/test/build-concurrency.test.js new file mode 100644 index 000000000000..5f99eefeb348 --- /dev/null +++ b/packages/astro/test/build-concurrency.test.js @@ -0,0 +1,29 @@ +import * as assert from 'node:assert/strict'; +import { before, describe, it } from 'node:test'; +import { loadFixture } from './test-utils.js'; + +describe('Building with concurrency > 1', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/build-concurrency/', + build: { + concurrency: 2, + }, + }); + }); + + it('Errors and exits', async () => { + let built = false + try { + await fixture.build(); + built = true + } catch (err) { + assert.match(err.message, /This is a test/) + } + + assert.equal(built, false, 'Build should not complete'); + }); +}); diff --git a/packages/astro/test/fixtures/build-concurrency/package.json b/packages/astro/test/fixtures/build-concurrency/package.json new file mode 100644 index 000000000000..d5dfaf4598e9 --- /dev/null +++ b/packages/astro/test/fixtures/build-concurrency/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/concurrency", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/build-concurrency/src/pages/index.astro b/packages/astro/test/fixtures/build-concurrency/src/pages/index.astro new file mode 100644 index 000000000000..3ce79d51ca0d --- /dev/null +++ b/packages/astro/test/fixtures/build-concurrency/src/pages/index.astro @@ -0,0 +1,5 @@ +--- +throw Error('This is a test') +--- + +

Hello world!

diff --git a/packages/astro/test/fixtures/build-concurrency/src/pages/page2.astro b/packages/astro/test/fixtures/build-concurrency/src/pages/page2.astro new file mode 100644 index 000000000000..ecfc83400ea5 --- /dev/null +++ b/packages/astro/test/fixtures/build-concurrency/src/pages/page2.astro @@ -0,0 +1,4 @@ +--- +--- + +

Page 2

diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 24d6fca45dfc..e817378c0375 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2414,6 +2414,12 @@ importers: specifier: ^10.26.4 version: 10.26.4 + packages/astro/test/fixtures/build-concurrency: + dependencies: + astro: + specifier: workspace:* + version: link:../../.. + packages/astro/test/fixtures/build-readonly-file: dependencies: astro: @@ -9950,7 +9956,6 @@ packages: libsql@0.5.4: resolution: {integrity: sha512-GEFeWca4SDAQFxjHWJBE6GK52LEtSskiujbG3rqmmeTO9t4sfSBKIURNLLpKDDF7fb7jmTuuRkDAn9BZGITQNw==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lightningcss-darwin-arm64@1.29.2: