Skip to content

Commit

Permalink
postinstall: Stop when any dependency errors
Browse files Browse the repository at this point in the history
`Promise.any` will only raise an exception when all of the promises have
rejected (or any promise has resolved); use `Promise.race` instead, where
the first rejecting promise raises.

Signed-off-by: Mark Yen <[email protected]>
  • Loading branch information
mook-as committed Sep 23, 2024
1 parent 5ed9ca4 commit 0204f55
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/postinstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ async function downloadDependencies(items: DependencyWithContext[]): Promise<voi

while (!abortSignal.aborted && running.size > done.size) {
const timeout = new Promise((resolve) => {
setTimeout(resolve, 60_000);
setTimeout(resolve, 5_000);
abortSignal.onabort = resolve;
});
const pending = Array.from(running).filter(v => !done.has(v));

await Promise.any([timeout, ...pending.map(v => promises[v])]);
await Promise.race([timeout, ...pending.map(v => promises[v])]);
}
abortSignal.onabort = null;

Expand Down

0 comments on commit 0204f55

Please sign in to comment.