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

Function isPromiseAwaitInternal

packages/react-server/src/ReactFlightServer.js:319–345  ·  view source on GitHub ↗
(url: string, functionName: string)

Source from the content-addressed store, hash-verified

317}
318
319function isPromiseAwaitInternal(url: string, functionName: string): boolean {
320 // Various internals of the JS VM can await internally on a Promise. If those are at
321 // the top of the stack then we don't want to consider them as internal frames. The
322 // true "await" conceptually is the thing that called the helper.
323 // Ideally we'd also include common third party helpers for this.
324 if (url === 'node:internal/async_hooks') {
325 // Ignore the stack frames from the async hooks themselves.
326 return true;
327 }
328 if (url !== '') {
329 return false;
330 }
331 switch (functionName) {
332 case 'Promise.then':
333 case 'Promise.catch':
334 case 'Promise.finally':
335 case 'Function.reject':
336 case 'Function.resolve':
337 case 'Function.all':
338 case 'Function.allSettled':
339 case 'Function.race':
340 case 'Function.try':
341 return true;
342 default:
343 return false;
344 }
345}
346
347export function isAwaitInUserspace(
348 request: Request,

Callers 1

isAwaitInUserspaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected