0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

fix: build stuck on unhandled promise reject (#191)

* fix: build stuck on unhandled promise reject

* Changeset
This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2021-05-10 09:35:40 -07:00 committed by GitHub
parent e0a4f5fbc0
commit e0fc2ca097
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
fix: build stuck on unhandled promise reject

View file

@ -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 shouldnt be a build error here
// there shouldnt 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)}]`);
/**