Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch uncaught promise build abort race #8600

Merged
merged 1 commit into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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