diff options
author | 2021-05-10 09:35:40 -0700 | |
---|---|---|
committer | 2021-05-10 11:35:40 -0500 | |
commit | e0fc2ca09752e9d96c47b25c451df24a01fbafcf (patch) | |
tree | 10093b3293fd0f2c31a85602908875afdb725cbd | |
parent | e0a4f5fbc05e8a0caeff064f4795ce94f85ec4e2 (diff) | |
download | astro-e0fc2ca09752e9d96c47b25c451df24a01fbafcf.tar.gz astro-e0fc2ca09752e9d96c47b25c451df24a01fbafcf.tar.zst astro-e0fc2ca09752e9d96c47b25c451df24a01fbafcf.zip |
fix: build stuck on unhandled promise reject (#191)
* fix: build stuck on unhandled promise reject
* Changeset
-rw-r--r-- | .changeset/young-mayflies-love.md | 5 | ||||
-rw-r--r-- | packages/astro/src/build.ts | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/.changeset/young-mayflies-love.md b/.changeset/young-mayflies-love.md new file mode 100644 index 000000000..c11787990 --- /dev/null +++ b/.changeset/young-mayflies-love.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +fix: build stuck on unhandled promise reject diff --git a/packages/astro/src/build.ts b/packages/astro/src/build.ts index e6a23bc95..262b4525b 100644 --- a/packages/astro/src/build.ts +++ b/packages/astro/src/build.ts @@ -115,7 +115,8 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { scanPromises.push( runtime.load(url).then((result) => { if (result.statusCode !== 200) { - throw new Error((result as any).error); // there shouldn’t be a build error here + // there shouldn’t be a build error here + throw (result as any).error || new Error(`unexpected status ${result.statusCode} when loading ${url}`); } buildState[url] = { srcPath: new URL(url, projectRoot), @@ -126,7 +127,12 @@ export async function build(astroConfig: AstroConfig): Promise<0 | 1> { ); } } - await Promise.all(scanPromises); + try { + await Promise.all(scanPromises); + } catch (err) { + error(logging, 'build', err); + return 1; + } debug(logging, 'build', `scanned deps [${stopTimer(timer.deps)}]`); /** |