Skip to content

Commit

Permalink
Fix module ID deduplication (facebook#20406)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and koto committed Jun 15, 2021
1 parent fd3271a commit 0bce339
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 0bce339

Please sign in to comment.