Skip to content

Instantly share code, notes, and snippets.

@danii
Last active February 20, 2021 05:03
Show Gist options
  • Save danii/f2835c4fb86916a227327c29f41d9327 to your computer and use it in GitHub Desktop.
Save danii/f2835c4fb86916a227327c29f41d9327 to your computer and use it in GitHub Desktop.
Information on node.js's stack traces.
//PseudoJSON {name:evaluateeFunc,file:evaluatee-file-name,line:evaluatee-line,column:evaluatee-column,evaluater:{name:middleEvaluater,evaluater:{name:evaluaterFunc,file:evaluater-file-name,line:evaluater-line,column:evaluater-column}}}
//Stack at {evaluateeFunc} (eval at {middleEvaluater} (eval at {evaluaterFunc} ({evaluater-file-name}:{evaluater-line}:{evaluater-column})), {evaluatee-file-name}:{evaluatee-line}:{evaluatee-column})
//PseudoJSON {name:evaluateeFunc,file:evaluatee-file-name,line:evaluatee-line,column:evaluatee-column,evaluater:{name:evaluaterFunc,file:evaluater-file-name,line:evaluater-line,column:evaluater-column}}
//Stack at {evaluateeFunc} (eval at {evaluaterFunc} ({evaluater-file-name}:{evaluater-line}:{evaluater-column}), {evaluatee-file-name}:{evaluatee-line}:{evaluatee-column})
//PsuedoJSON {name:funcName,file:file-name,line:line,column:column}
//Stack at {funcName} ({file-name}:{line}:{column})
//PseudoJSON {name:<anonymous>,file:file-name,line:line,column:column}
//Stack at {file-name}:{line}:{column}
//NOTES: native code will have "<anonymous>" as their file
// functions ran with new will have "new" before their name
const nodeStackFrame = /^\s*at\s+(.+?)(?:\s+\((.+?)\))?$/; //match 1: nodeFileDescriptor | functionName: string, match 2: nodeFileDescriptor | nodeEvalDescriptor | null
const nodeFileDescriptor = /^(.*?):(\d+):(\d+)$/; //match 1: fileName: string, match 2: line: number, match 3: column: number
const nodeEvalDescriptor = /^eval\s+at\s+(.*?)\s+\((.*?)\)(?:, (.*?))?$/; //match 1: evaluateeFunc: string, match 2: nodeFileDescriptor | nodeEvalDescriptor, match 3: nodeFileDescriptor | null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment