Home / Function/ collectStackTracePrivate() — react Function Reference

collectStackTracePrivate() — react Function Reference

Architecture documentation for the collectStackTracePrivate() function in ReactFlightStackConfigV8.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  3890a326_1e32_462e_feaa_0e71b5156b1f["collectStackTracePrivate()"]
  6b04fae3_e76f_58bb_e731_caa9abb4c49c["ReactFlightStackConfigV8.js"]
  3890a326_1e32_462e_feaa_0e71b5156b1f -->|defined in| 6b04fae3_e76f_58bb_e731_caa9abb4c49c
  61de8561_a281_51c1_9a70_41fe59211c78["collectStackTrace()"]
  61de8561_a281_51c1_9a70_41fe59211c78 -->|calls| 3890a326_1e32_462e_feaa_0e71b5156b1f
  a636622f_5efc_89d6_e0eb_f5e54b6cd41f["getMethodCallName()"]
  3890a326_1e32_462e_feaa_0e71b5156b1f -->|calls| a636622f_5efc_89d6_e0eb_f5e54b6cd41f
  style 3890a326_1e32_462e_feaa_0e71b5156b1f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-server/src/ReactFlightStackConfigV8.js lines 52–118

function collectStackTracePrivate(
  error: Error,
  structuredStackTrace: CallSite[],
): string {
  const result: ReactStackTrace = [];
  // Collect structured stack traces from the callsites.
  // We mirror how V8 serializes stack frames and how we later parse them.
  for (let i = framesToSkip; i < structuredStackTrace.length; i++) {
    const callSite = structuredStackTrace[i];
    let name = callSite.getFunctionName() || '<anonymous>';
    if (name.includes('react_stack_bottom_frame')) {
      // Skip everything after the bottom frame since it'll be internals.
      break;
    } else if (callSite.isNative()) {
      // $FlowFixMe[prop-missing]
      const isAsync = callSite.isAsync();
      result.push([name, '', 0, 0, 0, 0, isAsync]);
    } else {
      // We encode complex function calls as if they're part of the function
      // name since we cannot simulate the complex ones and they look the same
      // as function names in UIs on the client as well as stacks.
      if (callSite.isConstructor()) {
        name = 'new ' + name;
      } else if (!callSite.isToplevel()) {
        name = getMethodCallName(callSite);
      }
      if (name === '<anonymous>') {
        name = '';
      }
      let filename = callSite.getScriptNameOrSourceURL() || '<anonymous>';
      if (filename === '<anonymous>') {
        filename = '';
        if (callSite.isEval()) {
          const origin = callSite.getEvalOrigin();
          if (origin) {
            filename = origin.toString() + ', <anonymous>';
          }
        }
      }
      const line = callSite.getLineNumber() || 0;
      const col = callSite.getColumnNumber() || 0;
      const enclosingLine: number =
        // $FlowFixMe[prop-missing]
        typeof callSite.getEnclosingLineNumber === 'function'
          ? (callSite: any).getEnclosingLineNumber() || 0
          : 0;
      const enclosingCol: number =
        // $FlowFixMe[prop-missing]
        typeof callSite.getEnclosingColumnNumber === 'function'
          ? (callSite: any).getEnclosingColumnNumber() || 0
          : 0;
      // $FlowFixMe[prop-missing]
      const isAsync = callSite.isAsync();
      result.push([
        name,
        filename,
        line,
        col,
        enclosingLine,
        enclosingCol,
        isAsync,
      ]);
    }
  }
  collectedStackTrace = result;
  return '';
}

Domain

Subdomains

Frequently Asked Questions

What does collectStackTracePrivate() do?
collectStackTracePrivate() is a function in the react codebase, defined in packages/react-server/src/ReactFlightStackConfigV8.js.
Where is collectStackTracePrivate() defined?
collectStackTracePrivate() is defined in packages/react-server/src/ReactFlightStackConfigV8.js at line 52.
What does collectStackTracePrivate() call?
collectStackTracePrivate() calls 1 function(s): getMethodCallName.
What calls collectStackTracePrivate()?
collectStackTracePrivate() is called by 1 function(s): collectStackTrace.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free