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

Function callWithDebugContextInDEV

packages/react-server/src/ReactFlightServer.js:1411–1448  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  callback: A => T,
  arg: A,
)

Source from the content-addressed store, hash-verified

1409}
1410
1411function callWithDebugContextInDEV<A, T>(
1412 request: Request,
1413 task: Task,
1414 callback: A => T,
1415 arg: A,
1416): T {
1417 // We don't have a Server Component instance associated with this callback and
1418 // the nearest context is likely a Client Component being serialized. We create
1419 // a fake owner during this callback so we can get the stack trace from it.
1420 // This also gets sent to the client as the owner for the replaying log.
1421 const componentDebugInfo: ReactComponentInfo = {
1422 name: '',
1423 env: task.environmentName,
1424 key: null,
1425 owner: task.debugOwner,
1426 };
1427 // $FlowFixMe[cannot-write]
1428 componentDebugInfo.stack =
1429 task.debugStack === null
1430 ? null
1431 : filterStackTrace(request, parseStackTrace(task.debugStack, 1));
1432 // $FlowFixMe[cannot-write]
1433 componentDebugInfo.debugStack = task.debugStack;
1434 // $FlowFixMe[cannot-write]
1435 componentDebugInfo.debugTask = task.debugTask;
1436 const debugTask = task.debugTask;
1437 // We don't need the async component storage context here so we only set the
1438 // synchronous tracking of owner.
1439 setCurrentOwner(componentDebugInfo);
1440 try {
1441 if (debugTask) {
1442 return debugTask.run(callback.bind(null, arg));
1443 }
1444 return callback(arg);
1445 } finally {
1446 setCurrentOwner(null);
1447 }
1448}
1449
1450const voidHandler = () => {};
1451

Callers 5

createTaskFunction · 0.85
renderModelDestructiveFunction · 0.85
logPostponeFunction · 0.85
logRecoverableErrorFunction · 0.85

Calls 5

setCurrentOwnerFunction · 0.90
filterStackTraceFunction · 0.85
runMethod · 0.80
parseStackTraceFunction · 0.70
callbackFunction · 0.50

Tested by

no test coverage detected