Handle rejections to avoid uncaught rejections (#25272)

This commit is contained in:
Sebastian Markbåge 2022-09-14 23:22:27 -04:00 committed by GitHub
parent c5d06fdc5d
commit 0b54e00475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -58,6 +58,9 @@ export function resolveModuleReference<T>(
const chunkCache: Map<string, null | Promise<any>> = new Map();
const asyncModuleCache: Map<string, Thenable<any>> = new Map();
function ignoreReject() {
// We rely on rejected promises to be handled by another listener.
}
// Start preloading the modules since we might need them soon.
// This function doesn't suspend.
export function preloadModule<T>(
@ -72,7 +75,7 @@ export function preloadModule<T>(
const thenable = __webpack_chunk_load__(chunkId);
promises.push(thenable);
const resolve = chunkCache.set.bind(chunkCache, chunkId, null);
thenable.then(resolve);
thenable.then(resolve, ignoreReject);
chunkCache.set(chunkId, thenable);
} else if (entry !== null) {
promises.push(entry);