Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: refactor source map stack trace prepare #41698

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/internal/source_map/prepare_stack_trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ const prepareStackTrace = (globalThis, error, trace) => {
// Construct call site name based on: v8.dev/docs/stack-trace-api:
const fnName = t.getFunctionName() ?? t.getMethodName();
const originalName = `${t.getTypeName() !== 'global' ?
`${t.getTypeName()}.` : ''}${fnName ? fnName : '<anonymous>'}`;
`${t.getTypeName()}.` : ''}${fnName || '<anonymous>'}`;
// The original call site may have a different symbol name
// associated with it, use it:
const prefix = (name && name !== originalName) ?
`${name}` :
`${originalName ? originalName : ''}`;
`${originalName}`;
const hasName = !!(name || originalName);
const originalSourceNoScheme =
StringPrototypeStartsWith(originalSource, 'file://') ?
Expand Down Expand Up @@ -160,7 +160,7 @@ function getErrorSource(
let prefix = '';
for (const character of new SafeStringIterator(
StringPrototypeSlice(line, 0, originalColumn + 1))) {
prefix += (character === '\t') ? '\t' :
prefix += character === '\t' ? '\t' :
StringPrototypeRepeat(' ', getStringWidth(character));
}
prefix = StringPrototypeSlice(prefix, 0, -1); // The last character is '^'.
Expand Down