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

Function emitAsyncSequence

packages/react-server/src/ReactFlightServer.js:2466–2534  ·  view source on GitHub ↗
(
  request: Request,
  task: Task,
  node: AsyncSequence,
  alreadyForwardedDebugInfo: ?ReactDebugInfo,
  owner: null | ReactComponentInfo,
  stack: null | Error,
)

Source from the content-addressed store, hash-verified

2464}
2465
2466function emitAsyncSequence(
2467 request: Request,
2468 task: Task,
2469 node: AsyncSequence,
2470 alreadyForwardedDebugInfo: ?ReactDebugInfo,
2471 owner: null | ReactComponentInfo,
2472 stack: null | Error,
2473): void {
2474 const visited: Set<AsyncSequence | ReactDebugInfo> = new Set();
2475 if (__DEV__ && alreadyForwardedDebugInfo) {
2476 visited.add(alreadyForwardedDebugInfo);
2477 }
2478 const awaitedNode = visitAsyncNode(request, task, node, visited, task.time);
2479 if (awaitedNode === undefined) {
2480 // Undefined is used as a signal that we found an aborted await and that's good enough
2481 // anything derived from that aborted node might be irrelevant.
2482 } else if (awaitedNode !== null) {
2483 // Nothing in user space (unfiltered stack) awaited this.
2484 serializeIONode(request, awaitedNode, awaitedNode.promise);
2485 request.pendingChunks++;
2486 // We log the environment at the time when we ping which may be later than what the
2487 // environment was when we actually started awaiting.
2488 const env = (0, request.environmentName)();
2489 // If we don't have any thing awaited, the time we started awaiting was internal
2490 // when we yielded after rendering. The current task time is basically that.
2491 const debugInfo: ReactAsyncInfo = {
2492 awaited: ((awaitedNode: any): ReactIOInfo), // This is deduped by this reference.
2493 env: env,
2494 };
2495 if (__DEV__) {
2496 if (owner === null && stack === null) {
2497 // We have no location for the await. We can use the JSX callsite of the parent
2498 // as the await if this was just passed as a prop.
2499 if (task.debugOwner !== null) {
2500 // $FlowFixMe[cannot-write]
2501 debugInfo.owner = task.debugOwner;
2502 }
2503 if (task.debugStack !== null) {
2504 // $FlowFixMe[cannot-write]
2505 debugInfo.stack = filterStackTrace(
2506 request,
2507 parseStackTrace(task.debugStack, 1),
2508 );
2509 }
2510 } else {
2511 if (owner != null) {
2512 // $FlowFixMe[cannot-write]
2513 debugInfo.owner = owner;
2514 }
2515 if (stack != null) {
2516 // $FlowFixMe[cannot-write]
2517 debugInfo.stack = filterStackTrace(
2518 request,
2519 parseStackTrace(stack, 1),
2520 );
2521 }
2522 }
2523 }

Calls 8

visitAsyncNodeFunction · 0.85
serializeIONodeFunction · 0.85
filterStackTraceFunction · 0.85
advanceTaskTimeFunction · 0.85
emitDebugChunkFunction · 0.85
markOperationEndTimeFunction · 0.85
addMethod · 0.80
parseStackTraceFunction · 0.70

Tested by

no test coverage detected