MCPcopy
hub / github.com/facebook/react / emitConsoleChunk

Function emitConsoleChunk

packages/react-server/src/ReactFlightServer.js:5187–5230  ·  view source on GitHub ↗
(
  request: Request,
  methodName: string,
  owner: null | ReactComponentInfo,
  env: string,
  stackTrace: ReactStackTrace,
  args: Array<any>,
)

Source from the content-addressed store, hash-verified

5185}
5186
5187function emitConsoleChunk(
5188 request: Request,
5189 methodName: string,
5190 owner: null | ReactComponentInfo,
5191 env: string,
5192 stackTrace: ReactStackTrace,
5193 args: Array<any>,
5194): void {
5195 if (!__DEV__) {
5196 // These errors should never make it into a build so we don't need to encode them in codes.json
5197 // eslint-disable-next-line react-internal/prod-error-codes
5198 throw new Error(
5199 'emitConsoleChunk should never be called in production mode. This is a bug in React.',
5200 );
5201 }
5202
5203 // Ensure the owner is already outlined.
5204 if (owner != null) {
5205 outlineComponentInfo(request, owner);
5206 }
5207
5208 const payload = [methodName, stackTrace, owner, env];
5209 // $FlowFixMe[method-unbinding]
5210 payload.push.apply(payload, args);
5211 const objectLimit = request.deferredDebugObjects === null ? 500 : 10;
5212 let json = serializeDebugModel(
5213 request,
5214 objectLimit + stackTrace.length,
5215 payload,
5216 );
5217 if (json[0] !== '[') {
5218 // This looks like an error. Try a simpler object.
5219 json = serializeDebugModel(request, 10 + stackTrace.length, [
5220 methodName,
5221 stackTrace,
5222 owner,
5223 env,
5224 'Unknown Value: React could not send it from the server.',
5225 ]);
5226 }
5227 const row = ':W' + json + '\n';
5228 const processedChunk = stringToChunk(row);
5229 request.completedDebugChunks.push(processedChunk);
5230}
5231
5232function emitTimeOriginChunk(request: Request, timeOrigin: number): void {
5233 // We emit the time origin once. All ReactTimeInfo timestamps later in the stream

Callers 1

wrapperMethodFunction · 0.85

Calls 5

stringToChunkFunction · 0.90
outlineComponentInfoFunction · 0.85
serializeDebugModelFunction · 0.85
pushMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected