summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> 2021-05-10 09:35:40 -0700
committerGravatar GitHub <noreply@github.com> 2021-05-10 11:35:40 -0500
commite0fc2ca09752e9d96c47b25c451df24a01fbafcf (patch)
tree10093b3293fd0f2c31a85602908875afdb725cbd
parente0a4f5fbc05e8a0caeff064f4795ce94f85ec4e2 (diff)
downloadastro-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.md5
-rw-r--r--packages/astro/src/build.ts10
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)}]`);
/**