Skip to content

Commit

Permalink
Catch uncaught promise build abort race (#8600)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Nov 3, 2022
1 parent 625935b commit 29b054c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/core/core/src/RequestTracker.js
Expand Up @@ -150,7 +150,7 @@ export type RunAPI = {|
runRequest: <TInput, TResult>(
subRequest: Request<TInput, TResult>,
opts?: RunRequestOpts,
) => Async<TResult>,
) => Promise<TResult>,
|};

type RunRequestOpts = {|
Expand Down Expand Up @@ -885,7 +885,7 @@ export default class RequestTracker {
async getRequestResult<T>(
contentKey: ContentKey,
ifMatch?: string,
): Async<?T> {
): Promise<?T> {
let node = nullthrows(this.graph.getNodeByContentKey(contentKey));
invariant(node.type === 'request');

Expand Down Expand Up @@ -958,7 +958,7 @@ export default class RequestTracker {
async runRequest<TInput, TResult>(
request: Request<TInput, TResult>,
opts?: ?RunRequestOpts,
): Async<TResult> {
): Promise<TResult> {
let requestId = this.graph.hasContentKey(request.id)
? this.graph.getNodeIdByContentKey(request.id)
: undefined;
Expand Down Expand Up @@ -1068,7 +1068,7 @@ export default class RequestTracker {
runRequest: <TInput, TResult>(
subRequest: Request<TInput, TResult>,
opts?: RunRequestOpts,
): Async<TResult> => {
): Promise<TResult> => {
subRequestContentKeys.add(subRequest.id);
return this.runRequest<TInput, TResult>(subRequest, opts);
},
Expand Down
5 changes: 4 additions & 1 deletion packages/core/core/src/requests/WriteBundlesRequest.js
Expand Up @@ -113,7 +113,10 @@ async function run({input, api, farm, options}: RunInput) {
hashRefToNameHash,
bundleGraph,
});
writeEarlyPromises[bundle.id] = api.runRequest(writeBundleRequest);
let promise = api.runRequest(writeBundleRequest);
// If the promise rejects before we await it (below), we don't want to crash the build.
promise.catch(() => {});
writeEarlyPromises[bundle.id] = promise;
}
}),
);
Expand Down

0 comments on commit 29b054c

Please sign in to comment.