@samitouri / QOS-React-2 / commits / 0b54e00475

Handle rejections to avoid uncaught rejections (#25272)

Sebastian Markbåge committed Sep 14, 2022 at 23:22 UTC 0b54e0047598e255bcbb7e3aff23c26d7382c54d
1 file changed +4 -1
packages/react-server-dom-webpack/src/ReactFlightClientWebpackBundlerConfig.js
+4 -1
@@ -58,6 +58,9 @@ export function resolveModuleReference<T>(
58 const chunkCache: Map<string, null | Promise<any>> = new Map();
59 const asyncModuleCache: Map<string, Thenable<any>> = new Map();
60
61 +function ignoreReject() {
62 + // We rely on rejected promises to be handled by another listener.
63 +}
64 // Start preloading the modules since we might need them soon.
65 // This function doesn't suspend.
66 export function preloadModule<T>(
@@ -72,7 +75,7 @@ export function preloadModule<T>(
75 const thenable = __webpack_chunk_load__(chunkId);
76 promises.push(thenable);
77 const resolve = chunkCache.set.bind(chunkCache, chunkId, null);
75 - thenable.then(resolve);
78 + thenable.then(resolve, ignoreReject);
79 chunkCache.set(chunkId, thenable);
80 } else if (entry !== null) {
81 promises.push(entry);