Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,21 @@ let statCache = null;
function wrapModuleLoad(request, parent, isMain) {
const logLabel = `[${parent?.id || ''}] [${request}]`;
const traceLabel = `require('${request}')`;
const channel = onRequire();

startTimer(logLabel, traceLabel);

try {
return onRequire().traceSync(Module._load, {
__proto__: null,
parentFilename: parent?.filename,
id: request,
}, Module, request, parent, isMain);
if (channel.hasSubscribers) {
return onRequire().traceSync(Module._load, {
__proto__: null,
parentFilename: parent?.filename,
id: request,
}, Module, request, parent, isMain);
}
// No subscribers, skip the wrapping to avoid clobbering stack traces
// and debugging steps.
return Module._load(request, parent, isMain);
} finally {
endTimer(logLabel, traceLabel);
}
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/console/console.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ Trace: foo
at *
at *
at *
at *
1 change: 0 additions & 1 deletion test/fixtures/errors/force_colors.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ Error: Should include grayed stack trace
 at *
 at *
 at *
 at *

Node.js *
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
at *
at *
at *
at *
(Use `* --trace-warnings ...` to show where the warning was created)
(node:*) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https:*nodejs.org*api*cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
at *
at *
at *
at *
(node:*) Error: This was rejected
at *
at *
Expand All @@ -21,7 +20,6 @@
at *
at *
at *
at *
(node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
at *
at *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
*
*
*
*
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: false,
Expand Down
1 change: 0 additions & 1 deletion test/message/assert_throws_stack.out
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
at *
at *
at *
at *
at * {
generatedMessage: true,
code: 'ERR_ASSERTION',
Expand Down
1 change: 0 additions & 1 deletion test/message/internal_assert.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Please open an issue with this stack trace at https://github.com/nodejs/node/iss
at *
at *
at *
at *
at * {
code: 'ERR_INTERNAL_ASSERTION'
}
Expand Down
1 change: 0 additions & 1 deletion test/message/internal_assert_fail.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Please open an issue with this stack trace at https://github.com/nodejs/node/iss
at *
at *
at *
at *
at * {
code: 'ERR_INTERNAL_ASSERTION'
}
Expand Down
30 changes: 10 additions & 20 deletions test/message/util-inspect-error-cause.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Error: Number error cause
at *
at *
at *
at *
at * {
[cause]: 42
}
Expand All @@ -18,7 +17,6 @@ Error: Object cause
at *
at *
at *
at *
at * {
[cause]: {
message: 'Unique',
Expand All @@ -35,7 +33,6 @@ Error: undefined cause
at *
at *
at *
at *
at * {
[cause]: undefined
}
Expand All @@ -47,7 +44,6 @@ Error: cause that throws
at *
at *
at *
at *
at * {
[cause]: [Getter]
}
Expand All @@ -57,7 +53,7 @@ RangeError: New Stack Frames
[cause]: FoobarError: Individual message
at *
*[90m at *[39m
*[90m ... 6 lines matching cause stack trace ...*[39m
*[90m ... 5 lines matching cause stack trace ...*[39m
*[90m at *[39m {
status: *[32m'Feeling good'*[39m,
extraProperties: *[32m'Yes!'*[39m,
Expand All @@ -70,18 +66,17 @@ RangeError: New Stack Frames
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
}
}
Error: Stack causes
at *
*[90m at *[39m
*[90m ... 6 lines matching cause stack trace ...*[39m
*[90m ... 5 lines matching cause stack trace ...*[39m
*[90m at *[39m {
[cause]: FoobarError: Individual message
at *
*[90m at *[39m
*[90m ... 6 lines matching cause stack trace ...*[39m
*[90m ... 5 lines matching cause stack trace ...*[39m
*[90m at *[39m {
status: *[32m'Feeling good'*[39m,
extraProperties: *[32m'Yes!'*[39m,
Expand All @@ -94,7 +89,6 @@ Error: Stack causes
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
}
}
RangeError: New Stack Frames
Expand All @@ -103,12 +97,12 @@ RangeError: New Stack Frames
[cause]: Error: Stack causes
at *
*[90m at *[39m
*[90m ... 6 lines matching cause stack trace ...*[39m
*[90m ... 5 lines matching cause stack trace ...*[39m
*[90m at *[39m {
[cause]: FoobarError: Individual message
at *
*[90m at *[39m
*[90m ... 6 lines matching cause stack trace ...*[39m
*[90m ... 5 lines matching cause stack trace ...*[39m
*[90m at *[39m {
status: *[32m'Feeling good'*[39m,
extraProperties: *[32m'Yes!'*[39m,
Expand All @@ -121,7 +115,6 @@ RangeError: New Stack Frames
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
*[90m at *[39m
}
}
}
Expand All @@ -131,7 +124,7 @@ RangeError: New Stack Frames
[cause]: FoobarError: Individual message
at *
at *
... 6 lines matching cause stack trace ...
... 5 lines matching cause stack trace ...
at * {
status: 'Feeling good',
extraProperties: 'Yes!',
Expand All @@ -144,18 +137,17 @@ RangeError: New Stack Frames
at *
at *
at *
at *
}
}
Error: Stack causes
at *
at *
... 6 lines matching cause stack trace ...
... 5 lines matching cause stack trace ...
at * {
[cause]: FoobarError: Individual message
at *
at *
... 6 lines matching cause stack trace ...
... 5 lines matching cause stack trace ...
at *
status: 'Feeling good',
extraProperties: 'Yes!',
Expand All @@ -168,7 +160,6 @@ Error: Stack causes
at *
at *
at *
at *
}
}
RangeError: New Stack Frames
Expand All @@ -177,12 +168,12 @@ RangeError: New Stack Frames
[cause]: Error: Stack causes
at *
at *
... 6 lines matching cause stack trace ...
... 5 lines matching cause stack trace ...
at * {
[cause]: FoobarError: Individual message
at *
at *
... 6 lines matching cause stack trace ...
... 5 lines matching cause stack trace ...
at * {
status: 'Feeling good',
extraProperties: 'Yes!',
Expand All @@ -195,7 +186,6 @@ RangeError: New Stack Frames
at *
at *
at *
at *
}
}
}
5 changes: 0 additions & 5 deletions test/message/util_inspect_error.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
at *
at *
at *
at *
nested:
{ err:
Error: foo
Expand All @@ -22,7 +21,6 @@
at *
at *
at *
at *
{
err: Error: foo
bar
Expand All @@ -34,7 +32,6 @@
at *
at *
at *
at *
nested: {
err: Error: foo
bar
Expand All @@ -46,7 +43,6 @@
at *
at *
at *
at *
}
}
{ Error: foo
Expand All @@ -59,5 +55,4 @@ bar
at *
at *
at *
at *
foo: 'bar' }
4 changes: 0 additions & 4 deletions test/pseudo-tty/console_colors.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ foobar
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m

Error: Should not ever get here.
at Object.<anonymous> [90m(*node_modules*[4m*node_modules*[24m*bar.js:*:*[90m)[39m
Expand All @@ -23,7 +22,6 @@ Error: Should not ever get here.
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m
at Object.<anonymous> [90m(*console_colors.js:*:*[90m)[39m
[90m at *[39m
Expand All @@ -33,7 +31,6 @@ Error: Should not ever get here.
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m

Error
at evalmachine.<anonymous>:*:*
Expand All @@ -47,4 +44,3 @@ Error
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m
1 change: 0 additions & 1 deletion test/pseudo-tty/test-fatal-error.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ TypeError: foobar
[90m at *(node:internal*loader:*:*)[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m
[90m at *[39m {
bla: [33mtrue[39m
}
Expand Down
1 change: 0 additions & 1 deletion test/pseudo-tty/test-start-trace-sigint.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ KEYBOARD_INTERRUPT: Script execution was interrupted by `SIGINT`
at *
at *
at *
at *
1 change: 0 additions & 1 deletion test/pseudo-tty/test-trace-sigint.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ KEYBOARD_INTERRUPT: Script execution was interrupted by `SIGINT`
at *
at *
at *
at *
Loading