Skip to content

Commit

Permalink
Handle rejections to avoid uncaught rejections
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Sep 15, 2022
1 parent c5d06fd commit 311ac8b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand All @@ -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);
Expand Down

0 comments on commit 311ac8b

Please sign in to comment.