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

test: remove CommonJS loader from stack traces #44197

Merged
merged 1 commit into from
Aug 14, 2022
Merged
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
2 changes: 2 additions & 0 deletions test/message/core_line_numbers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
Error.stackTraceLimit = 3;

const punycode = require('punycode');

// This test verifies that line numbers in core modules are reported correctly.
Expand Down
6 changes: 0 additions & 6 deletions test/message/core_line_numbers.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ RangeError: Invalid input
at error (node:punycode:52:8)
at Object.decode (node:punycode:*:*)
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*

Node.js *
2 changes: 2 additions & 0 deletions test/message/error_aggregateTwoErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
'use strict';

require('../common');
Error.stackTraceLimit = 1;

const { aggregateTwoErrors } = require('internal/errors');

const originalError = new Error('original');
Expand Down
25 changes: 3 additions & 22 deletions test/message/error_aggregateTwoErrors.out
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
*error_aggregateTwoErrors.js:*
throw aggregateTwoErrors(err, originalError);
^
AggregateError: original
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
[AggregateError: original] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this change is needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t understand why this output changed either.

code: 'ERR0',
[errors]: [
Error: original
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*) {
code: 'ERR0'
},
Error: second error
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*) {
code: 'ERR1'
}
]
Expand Down
2 changes: 2 additions & 0 deletions test/message/error_exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

'use strict';
require('../common');
Error.stackTraceLimit = 1;

const assert = require('assert');

process.on('exit', function(code) {
Expand Down
8 changes: 1 addition & 7 deletions test/message/error_exit.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

1 !== 2

at Object.<anonymous> (*test*message*error_exit.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
at Object.<anonymous> (*test*message*error_exit.js:*:*) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: 1,
Expand Down
1 change: 1 addition & 0 deletions test/message/error_with_nul.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
require('../common');
Error.stackTraceLimit = 2;

function test() {
const a = 'abc\0def';
Expand Down
Binary file modified test/message/error_with_nul.out
Binary file not shown.
2 changes: 2 additions & 0 deletions test/message/events_unhandled_error_common_trace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
Error.stackTraceLimit = 2;

const EventEmitter = require('events');

function foo() {
Expand Down
10 changes: 0 additions & 10 deletions test/message/events_unhandled_error_common_trace.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,8 @@ node:events:*
Error: foo:bar
at bar (*events_unhandled_error_common_trace.js:*:*)
at foo (*events_unhandled_error_common_trace.js:*:*)
at Object.<anonymous> (*events_unhandled_error_common_trace.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
Emitted 'error' event at:
at quux (*events_unhandled_error_common_trace.js:*:*)
at Object.<anonymous> (*events_unhandled_error_common_trace.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
[... lines matching original stack trace ...]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's the only test checking this line, maybe we should also move it to a JS test with RegExp.

at node:internal/main/run_main_module:*:*

Node.js *
2 changes: 2 additions & 0 deletions test/message/events_unhandled_error_nexttick.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
Error.stackTraceLimit = 1;

const EventEmitter = require('events');
const er = new Error();
process.nextTick(() => {
Expand Down
7 changes: 0 additions & 7 deletions test/message/events_unhandled_error_nexttick.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_nexttick.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
Emitted 'error' event at:
at *events_unhandled_error_nexttick.js:*:*
at process.processTicksAndRejections (node:internal/process/task_queues:*:*)

Node.js *
2 changes: 2 additions & 0 deletions test/message/events_unhandled_error_sameline.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';
require('../common');
Error.stackTraceLimit = 1;

const EventEmitter = require('events');
new EventEmitter().emit('error', new Error());
9 changes: 0 additions & 9 deletions test/message/events_unhandled_error_sameline.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_sameline.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
Emitted 'error' event at:
at Object.<anonymous> (*events_unhandled_error_sameline.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
[... lines matching original stack trace ...]
at node:internal/main/run_main_module:*:*

Node.js *
2 changes: 2 additions & 0 deletions test/message/events_unhandled_error_subclass.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';
require('../common');
Error.stackTraceLimit = 1;

const EventEmitter = require('events');
class Foo extends EventEmitter {}
new Foo().emit('error', new Error());
9 changes: 0 additions & 9 deletions test/message/events_unhandled_error_subclass.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_subclass.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
Emitted 'error' event on Foo instance at:
at Object.<anonymous> (*events_unhandled_error_subclass.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
[... lines matching original stack trace ...]
at node:internal/main/run_main_module:*:*

Node.js *
2 changes: 2 additions & 0 deletions test/message/if-error-has-good-stack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

require('../common');
Error.stackTraceLimit = 4;

const assert = require('assert');

let err;
Expand Down
16 changes: 2 additions & 14 deletions test/message/if-error-has-good-stack.out
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,14 @@ AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
at c (*if-error-has-good-stack.js:*:*)
at b (*if-error-has-good-stack.js:*:*)
at a (*if-error-has-good-stack.js:*:*)
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:* {
at Object.<anonymous> (*if-error-has-good-stack.js:*:*) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: Error: test error
at c (*if-error-has-good-stack.js:*:*)
at b (*if-error-has-good-stack.js:*:*)
at a (*if-error-has-good-stack.js:*:*)
at Object.<anonymous> (*if-error-has-good-stack.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
at Object.<anonymous> (*if-error-has-good-stack.js:*:*),
expected: null,
operator: 'ifError'
}
Expand Down
1 change: 1 addition & 0 deletions test/message/source_map_disabled_by_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

'use strict';
require('../common');
Error.stackTraceLimit = 5;

process.setSourceMapsEnabled(false);

Expand Down
10 changes: 0 additions & 10 deletions test/message/source_map_disabled_by_api.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ Error: an error!
at functionB (*enclosing-call-site-min.js:1:60)
at functionA (*enclosing-call-site-min.js:1:26)
at Object.<anonymous> (*enclosing-call-site-min.js:1:199)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
Error: an error!
at functionD (*enclosing-call-site.js:16:17)
at functionC (*enclosing-call-site.js:10:3)
at functionB (*enclosing-call-site.js:6:3)
at functionA (*enclosing-call-site.js:2:3)
at Object.<anonymous> (*enclosing-call-site.js:24:3)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
1 change: 1 addition & 0 deletions test/message/source_map_enabled_by_api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
require('../common');
Error.stackTraceLimit = 5;

process.setSourceMapsEnabled(true);

Expand Down
10 changes: 0 additions & 10 deletions test/message/source_map_enabled_by_api.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ Error: an error!
at functionB (*enclosing-call-site.js:6:3)
at functionA (*enclosing-call-site.js:2:3)
at Object.<anonymous> (*enclosing-call-site.js:24:3)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
Error: an error!
at functionD (*enclosing-call-site-min.js:1:156)
at functionC (*enclosing-call-site-min.js:1:97)
at functionB (*enclosing-call-site-min.js:1:60)
at functionA (*enclosing-call-site-min.js:1:26)
at Object.<anonymous> (*enclosing-call-site-min.js:1:199)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
2 changes: 2 additions & 0 deletions test/message/source_map_enclosing_function.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

'use strict';
require('../common');
Error.stackTraceLimit = 5;

require('../fixtures/source-map/enclosing-call-site-min.js');
5 changes: 0 additions & 5 deletions test/message/source_map_enclosing_function.out
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@ Error: an error!
at functionB (*enclosing-call-site.js:6:3)
at functionA (*enclosing-call-site.js:2:3)
at Object.<anonymous> (*enclosing-call-site.js:24:3)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)

Node.js *
2 changes: 2 additions & 0 deletions test/message/source_map_eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

'use strict';
require('../common');
Error.stackTraceLimit = 3;

const fs = require('fs');

const content = fs.readFileSync(require.resolve('../fixtures/source-map/tabs.js'), 'utf8');
Expand Down
8 changes: 1 addition & 7 deletions test/message/source_map_eval.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
ReferenceError: alert is not defined
at Object.eval (*tabs.coffee:26:2)
at eval (*tabs.coffee:1:14)
at Object.<anonymous> (*source_map_eval.js:8:1)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*)
at node:internal/main/run_main_module:*
at Object.<anonymous> (*source_map_eval.js:*:*)

Node.js *
1 change: 1 addition & 0 deletions test/message/source_map_no_source_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

'use strict';
require('../common');
Error.stackTraceLimit = 2;

require('../fixtures/source-map/no-source.js');
8 changes: 0 additions & 8 deletions test/message/source_map_no_source_file.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@
Error: foo
at Throw (*file-not-exists.ts:2:9)
at Object.<anonymous> (*file-not-exists.ts:5:1)
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
at require (node:internal/modules/cjs/helpers:*)
at Object.<anonymous> (*source_map_no_source_file.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:*)

Node.js *
2 changes: 2 additions & 0 deletions test/message/source_map_reference_error_tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

'use strict';
require('../common');
Error.stackTraceLimit = 2;

require('../fixtures/source-map/tabs.js');
8 changes: 0 additions & 8 deletions test/message/source_map_reference_error_tabs.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@
ReferenceError: alert is not defined
at *tabs.coffee:26:2*
at *tabs.coffee:1:14*
at Module._compile (node:internal/modules/cjs/loader:*
at Module._extensions..js (node:internal/modules/cjs/loader:*
at Module.load (node:internal/modules/cjs/loader:*
at Module._load (node:internal/modules/cjs/loader:*
at Module.require (node:internal/modules/cjs/loader:*
at require (node:internal/modules/cjs/helpers:*
at Object.<anonymous> (*source_map_reference_error_tabs.js:*
at Module._compile (node:internal/modules/cjs/loader:*

Node.js *
2 changes: 2 additions & 0 deletions test/message/source_map_throw_catch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

'use strict';
require('../common');
Error.stackTraceLimit = 2;

try {
require('../fixtures/source-map/typescript-throw');
} catch (err) {
Expand Down
8 changes: 0 additions & 8 deletions test/message/source_map_throw_catch.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,3 @@ reachable
Error: an exception
at *typescript-throw.ts:18:11*
at *typescript-throw.ts:24:1*
at Module._compile (node:internal/modules/cjs/loader:*)
at Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
at require (node:internal/modules/cjs/helpers:*)
at Object.<anonymous> (*source_map_throw_catch.js:6:3)
at Module._compile (node:internal/modules/cjs/loader:*)
Loading