( request: Request, ioNode: IONode | PromiseNode | UnresolvedPromiseNode, promiseRef: null | WeakRef<Promise<mixed>>, )
| 4433 | } |
| 4434 | |
| 4435 | function serializeIONode( |
| 4436 | request: Request, |
| 4437 | ioNode: IONode | PromiseNode | UnresolvedPromiseNode, |
| 4438 | promiseRef: null | WeakRef<Promise<mixed>>, |
| 4439 | ): string { |
| 4440 | const existingRef = request.writtenDebugObjects.get(ioNode); |
| 4441 | if (existingRef !== undefined) { |
| 4442 | // Already written |
| 4443 | return existingRef; |
| 4444 | } |
| 4445 | |
| 4446 | let stack = null; |
| 4447 | let name = ''; |
| 4448 | if (ioNode.stack !== null) { |
| 4449 | // The stack can contain some leading internal frames for the construction of the promise that we skip. |
| 4450 | const fullStack = stripLeadingPromiseCreationFrames(ioNode.stack); |
| 4451 | stack = filterStackTrace(request, fullStack); |
| 4452 | name = findCalledFunctionNameFromStackTrace(request, fullStack); |
| 4453 | // The name can include the object that this was called on but sometimes that's |
| 4454 | // just unnecessary context. |
| 4455 | if (name.startsWith('Window.')) { |
| 4456 | name = name.slice(7); |
| 4457 | } else if (name.startsWith('<anonymous>.')) { |
| 4458 | name = name.slice(7); |
| 4459 | } |
| 4460 | } |
| 4461 | const owner = ioNode.owner; |
| 4462 | // Ensure the owner is already outlined. |
| 4463 | if (owner != null) { |
| 4464 | outlineComponentInfo(request, owner); |
| 4465 | } |
| 4466 | |
| 4467 | let value: void | Promise<mixed> = undefined; |
| 4468 | if (promiseRef !== null) { |
| 4469 | value = promiseRef.deref(); |
| 4470 | } |
| 4471 | |
| 4472 | // We log the environment at the time when we serialize the I/O node. |
| 4473 | // The environment name may have changed from when the I/O was actually started. |
| 4474 | const env = (0, request.environmentName)(); |
| 4475 | |
| 4476 | const endTime = |
| 4477 | ioNode.tag === UNRESOLVED_PROMISE_NODE |
| 4478 | ? // Mark the end time as now. It's arbitrary since it's not resolved but this |
| 4479 | // marks when we called abort and therefore stopped trying. |
| 4480 | request.abortTime |
| 4481 | : ioNode.end; |
| 4482 | |
| 4483 | request.pendingDebugChunks++; |
| 4484 | const id = request.nextChunkId++; |
| 4485 | emitIOInfoChunk( |
| 4486 | request, |
| 4487 | id, |
| 4488 | name, |
| 4489 | ioNode.start, |
| 4490 | endTime, |
| 4491 | value, |
| 4492 | env, |
no test coverage detected