initAsyncDebugInfo() — react Function Reference
Architecture documentation for the initAsyncDebugInfo() function in ReactFlightServerConfigDebugNode.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD fb7110d7_ae16_b760_ff60_4b830c5c66b9["initAsyncDebugInfo()"] e13213e5_bbf2_d841_8c5b_fc4a5aece086["ReactFlightServerConfigDebugNode.js"] fb7110d7_ae16_b760_ff60_4b830c5c66b9 -->|defined in| e13213e5_bbf2_d841_8c5b_fc4a5aece086 f3a435f4_2e07_e81b_ee77_ae12bfb98f5d["resolvePromiseOrAwaitNode()"] fb7110d7_ae16_b760_ff60_4b830c5c66b9 -->|calls| f3a435f4_2e07_e81b_ee77_ae12bfb98f5d style fb7110d7_ae16_b760_ff60_4b830c5c66b9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-server/src/ReactFlightServerConfigDebugNode.js lines 62–388
export function initAsyncDebugInfo(): void {
if (__DEV__ && enableAsyncDebugInfo) {
createHook({
init(
asyncId: number,
type: string,
triggerAsyncId: number,
resource: any,
): void {
const trigger = pendingOperations.get(triggerAsyncId);
let node: AsyncSequence;
if (type === 'PROMISE') {
const currentAsyncId = executionAsyncId();
if (currentAsyncId !== triggerAsyncId) {
// When you call .then() on a native Promise, or await/Promise.all() a thenable,
// then this intermediate Promise is created. We use this as our await point
if (trigger === undefined) {
// We don't track awaits on things that started outside our tracked scope.
return;
}
// If the thing we're waiting on is another Await we still track that sequence
// so that we can later pick the best stack trace in user space.
let stack = null;
let promiseRef: WeakRef<Promise<any>>;
if (
trigger.stack !== null &&
(trigger.tag === AWAIT_NODE ||
trigger.tag === UNRESOLVED_AWAIT_NODE)
) {
// We already had a stack for an await. In a chain of awaits we'll only need one good stack.
// We mark it with an empty stack to signal to any await on this await that we have a stack.
stack = emptyStack;
if (resource._debugInfo !== undefined) {
// We may need to forward this debug info at the end so we need to retain this promise.
promiseRef = new WeakRef((resource: Promise<any>));
} else {
// Otherwise, we can just refer to the inner one since that's the one we'll log anyway.
promiseRef = trigger.promise;
}
} else {
promiseRef = new WeakRef((resource: Promise<any>));
const request = resolveRequest();
if (request === null) {
// We don't collect stacks for awaits that weren't in the scope of a specific render.
} else {
stack = parseStackTracePrivate(new Error(), 5);
if (stack !== null && !isAwaitInUserspace(request, stack)) {
// If this await was not done directly in user space, then clear the stack. We won't use it
// anyway. This lets future awaits on this await know that we still need to get their stacks
// until we find one in user space.
stack = null;
}
}
}
const current = pendingOperations.get(currentAsyncId);
node = ({
tag: UNRESOLVED_AWAIT_NODE,
owner: resolveOwner(),
stack: stack,
start: performance.now(),
end: -1.1, // set when resolved.
promise: promiseRef,
awaited: trigger, // The thing we're awaiting on. Might get overrriden when we resolve.
previous: current === undefined ? null : current, // The path that led us here.
}: UnresolvedAwaitNode);
} else {
const owner = resolveOwner();
node = ({
tag: UNRESOLVED_PROMISE_NODE,
owner: owner,
stack:
owner === null ? null : parseStackTracePrivate(new Error(), 5),
start: performance.now(),
end: -1.1, // Set when we resolve.
promise: new WeakRef((resource: Promise<any>)),
awaited:
trigger === undefined
? null // It might get overridden when we resolve.
: trigger,
previous: null,
}: UnresolvedPromiseNode);
Domain
Subdomains
Source
Frequently Asked Questions
What does initAsyncDebugInfo() do?
initAsyncDebugInfo() is a function in the react codebase, defined in packages/react-server/src/ReactFlightServerConfigDebugNode.js.
Where is initAsyncDebugInfo() defined?
initAsyncDebugInfo() is defined in packages/react-server/src/ReactFlightServerConfigDebugNode.js at line 62.
What does initAsyncDebugInfo() call?
initAsyncDebugInfo() calls 1 function(s): resolvePromiseOrAwaitNode.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free