MCPcopy Index your code
hub / github.com/react/react / emitOutlinedDebugModelChunk

Function emitOutlinedDebugModelChunk

packages/react-server/src/ReactFlightServer.js:5103–5166  ·  view source on GitHub ↗
(
  request: Request,
  id: number,
  counter: {objectLimit: number},
  model: ReactClientValue,
)

Source from the content-addressed store, hash-verified

5101}
5102
5103function emitOutlinedDebugModelChunk(
5104 request: Request,
5105 id: number,
5106 counter: {objectLimit: number},
5107 model: ReactClientValue,
5108): void {
5109 if (!__DEV__) {
5110 // These errors should never make it into a build so we don't need to encode them in codes.json
5111 // eslint-disable-next-line react-internal/prod-error-codes
5112 throw new Error(
5113 'emitOutlinedDebugModel should never be called in production mode. This is a bug in React.',
5114 );
5115 }
5116
5117 if (typeof model === 'object' && model !== null) {
5118 // We can't limit outlined values.
5119 doNotLimit.add(model);
5120 }
5121
5122 function replacer(
5123 this:
5124 | {+[key: string | number]: ReactClientValue}
5125 | $ReadOnlyArray<ReactClientValue>,
5126 parentPropertyName: string,
5127 value: ReactClientValue,
5128 ): ReactJSONValue {
5129 try {
5130 return renderDebugModel(
5131 request,
5132 counter,
5133 this,
5134 parentPropertyName,
5135 value,
5136 );
5137 } catch (x) {
5138 return (
5139 'Unknown Value: React could not send it from the server.\n' + x.message
5140 );
5141 }
5142 }
5143
5144 const prevModelRoot = debugModelRoot;
5145 debugModelRoot = model;
5146 if (typeof model === 'object' && model !== null) {
5147 // Future references can refer to this object by id.
5148 request.writtenDebugObjects.set(model, serializeByValueID(id));
5149 }
5150 let json: string;
5151 try {
5152 // $FlowFixMe[incompatible-cast] stringify can return null
5153 json = (stringify(model, replacer): string);
5154 } catch (x) {
5155 // $FlowFixMe[incompatible-cast] stringify can return null
5156 json = (stringify(
5157 'Unknown Value: React could not send it from the server.\n' + x.message,
5158 ): string);
5159 } finally {
5160 debugModelRoot = prevModelRoot;

Callers 6

serializeDebugThenableFunction · 0.85
progressFunction · 0.85
renderDebugModelFunction · 0.85
outlineDebugModelFunction · 0.85
resolveDebugMessageFunction · 0.85

Calls 7

stringToChunkFunction · 0.90
stringifyFunction · 0.85
addMethod · 0.80
setMethod · 0.80
serializeByValueIDFunction · 0.70
toStringMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected