@@ -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 ) ;
@@ -517,6 +519,11 @@ export function resolveModelToJSON(
517519 }
518520
519521 if ( typeof value === 'symbol ') {
522+ const writtenSymbols = request . writtenSymbols ;
523+ const existingId = writtenSymbols . get ( value ) ;
524+ if ( existingId !== undefined ) {
525+ return serializeByValueID ( existingId ) ;
526+ }
520527 const name = value . description ;
521528 invariant (
522529 Symbol . for ( name ) === value ,
@@ -530,6 +537,7 @@ export function resolveModelToJSON(
530537 request . pendingChunks ++ ;
531538 const symbolId = request . nextChunkId ++ ;
532539 emitSymbolChunk ( request , symbolId , name ) ;
540+ writtenSymbols . set ( value , symbolId ) ;
533541 return serializeByValueID ( symbolId ) ;
534542 }
535543
0 commit comments