@@ -78,6 +78,7 @@ export type Request = {
7878 completedModuleChunks : Array < Chunk > ,
7979 completedJSONChunks : Array < Chunk > ,
8080 completedErrorChunks : Array < Chunk > ,
81+ writtenSymbols : Map < Symbol , number> ,
8182 flowing : boolean ,
8283 toJSON : ( key : string , value : ReactModel ) => ReactJSONValue ,
8384} ;
@@ -99,6 +100,7 @@ export function createRequest(
99100 completedModuleChunks : [ ] ,
100101 completedJSONChunks : [ ] ,
101102 completedErrorChunks : [ ] ,
103+ writtenSymbols : new Map ( ) ,
102104 flowing : false ,
103105 toJSON : function ( key : string , value : ReactModel ) : ReactJSONValue {
104106 return resolveModelToJSON ( request , this , key , value ) ;
@@ -522,6 +524,11 @@ export function resolveModelToJSON(
522524 }
523525
524526 if ( typeof value === 'symbol ') {
527+ const writtenSymbols = request . writtenSymbols ;
528+ const existingId = writtenSymbols . get ( value ) ;
529+ if ( existingId !== undefined ) {
530+ return serializeByValueID ( existingId ) ;
531+ }
525532 const name = value . description ;
526533 invariant (
527534 Symbol . for ( name ) === value ,
@@ -535,6 +542,7 @@ export function resolveModelToJSON(
535542 request . pendingChunks ++ ;
536543 const symbolId = request . nextChunkId ++ ;
537544 emitSymbolChunk ( request , symbolId , name ) ;
545+ writtenSymbols . set ( value , symbolId ) ;
538546 return serializeByValueID ( symbolId ) ;
539547 }
540548
0 commit comments