@samitouri / QOS-React-2 / commits / 1b5ca99063

Fix module ID deduplication (#20406)

Dan Abramov committed Dec 8, 2020 at 13:19 UTC 1b5ca99063414146048886c632256cdd3002c5a0
1 file changed +3 -1
packages/react-server/src/ReactFlightServer.js
+3 -1
@@ -432,7 +432,8 @@ export function resolveModelToJSON(
432 if (isModuleReference(value)) {
433 const moduleReference: ModuleReference<any> = (value: any);
434 const moduleKey: ModuleKey = getModuleKey(moduleReference);
435 - const existingId = request.writtenModules.get(moduleKey);
435 + const writtenModules = request.writtenModules;
436 + const existingId = writtenModules.get(moduleKey);
437 if (existingId !== undefined) {
438 return serializeByValueID(existingId);
439 }
@@ -444,6 +445,7 @@ export function resolveModelToJSON(
445 request.pendingChunks++;
446 const moduleId = request.nextChunkId++;
447 emitModuleChunk(request, moduleId, moduleMetaData);
448 + writtenModules.set(moduleKey, moduleId);
449 if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
450 // If we're encoding the "type" of an element, we can refer
451 // to that by a lazy reference instead of directly since React