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

Function isAwaitInUserspace

packages/react-server/src/ReactFlightServer.js:347–373  ·  view source on GitHub ↗
(
  request: Request,
  stack: ReactStackTrace,
)

Source from the content-addressed store, hash-verified

345}
346
347export function isAwaitInUserspace(
348 request: Request,
349 stack: ReactStackTrace,
350): boolean {
351 let firstFrame = 0;
352 while (
353 stack.length > firstFrame &&
354 isPromiseAwaitInternal(stack[firstFrame][1], stack[firstFrame][0])
355 ) {
356 // Skip the internal frame that awaits itself.
357 firstFrame++;
358 }
359 if (stack.length > firstFrame) {
360 // Check if the very first stack frame that awaited this Promise was in user space.
361 // TODO: This doesn't take into account wrapper functions such as our fake .then()
362 // in FlightClient which will always be considered third party awaits if you call
363 // .then directly.
364 const filterStackFrame = request.filterStackFrame;
365 const callsite = stack[firstFrame];
366 const functionName = callsite[0];
367 const url = devirtualizeURL(callsite[1]);
368 const lineNumber = callsite[2];
369 const columnNumber = callsite[3];
370 return filterStackFrame(url, functionName, lineNumber, columnNumber);
371 }
372 return false;
373}
374
375initAsyncDebugInfo();
376

Callers 2

initFunction · 0.90
visitAsyncNodeFunction · 0.85

Calls 3

isPromiseAwaitInternalFunction · 0.85
devirtualizeURLFunction · 0.85
filterStackFrameFunction · 0.50

Tested by

no test coverage detected