Skip to content

Commit

Permalink
Fix module ID deduplication (#20406)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 8, 2020
1 parent 5fd9db7 commit 1b5ca99
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-server/src/ReactFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ export function resolveModelToJSON(
if (isModuleReference(value)) {
const moduleReference: ModuleReference<any> = (value: any);
const moduleKey: ModuleKey = getModuleKey(moduleReference);
const existingId = request.writtenModules.get(moduleKey);
const writtenModules = request.writtenModules;
const existingId = writtenModules.get(moduleKey);
if (existingId !== undefined) {
return serializeByValueID(existingId);
}
Expand All @@ -444,6 +445,7 @@ export function resolveModelToJSON(
request.pendingChunks++;
const moduleId = request.nextChunkId++;
emitModuleChunk(request, moduleId, moduleMetaData);
writtenModules.set(moduleKey, moduleId);
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
// If we're encoding the "type" of an element, we can refer
// to that by a lazy reference instead of directly since React
Expand Down

0 comments on commit 1b5ca99

Please sign in to comment.