( request: Request, task: Task, callback: A => T, arg: A, )
| 1409 | } |
| 1410 | |
| 1411 | function 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 | |
| 1450 | const voidHandler = () => {}; |
| 1451 |
no test coverage detected