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

[v16.x backport] test: remove cjs loader from stack traces #46535

Closed
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,9 +6,3 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.Module._load (node:internal/modules/cjs/loader:*:*)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:*:*)
at node:internal/main/run_main_module:*:*
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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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] {
code: 'ERR0',
[errors]: [
Error: original
at Object.<anonymous> (*test*message*error_aggregateTwoErrors.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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,16 +5,6 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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 ...]
at node:internal/main/run_main_module:*:*
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,12 +4,5 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_nexttick.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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 processTicksAndRejections (node:internal/process/task_queues:*:*)
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,14 +4,5 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_sameline.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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:*:*
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,14 +4,5 @@ node:events:*

Error
at Object.<anonymous> (*events_unhandled_error_subclass.js:*:*)
at Module._compile (node:internal/modules/cjs/loader:*:*)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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:*:*
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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*:*)
at Module.load (node:internal/modules/cjs/loader:*:*)
at Function.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'
}
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,11 +4,6 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
*enclosing-call-site.js:16
throw new Error('an error!')
^
Expand All @@ -19,8 +14,3 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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 @@ -8,11 +8,6 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.Module._load (node:internal/modules/cjs/loader:*)
at Module.require (node:internal/modules/cjs/loader:*)
*enclosing-call-site-min.js:1
var functionA=function(){functionB()};function functionB(){functionC()}var functionC=function(){functionD()},functionD=function(){if(0<Math.random())throw Error("an error!");},thrower=functionA;try{functionA()}catch(a){throw a;};
^
Expand All @@ -23,8 +18,3 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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,8 +8,3 @@ 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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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_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
@@ -1,10 +1,4 @@
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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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:*:*)
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,11 +5,3 @@
ReferenceError: alert is not defined
at *tabs.coffee:26:2*
at *tabs.coffee:1:14*
at Module._compile (node:internal/modules/cjs/loader:*
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*
at Module.load (node:internal/modules/cjs/loader:*
at Function.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:*
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 @@ -5,11 +5,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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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:*)
2 changes: 2 additions & 0 deletions test/message/source_map_throw_first_tick.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/typescript-throw');
8 changes: 0 additions & 8 deletions test/message/source_map_throw_first_tick.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,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 Object.Module._extensions..js (node:internal/modules/cjs/loader:*)
at Module.load (node:internal/modules/cjs/loader:*)
at Function.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_first_tick.js:5:1)
at Module._compile (node:internal/modules/cjs/loader:*)
2 changes: 2 additions & 0 deletions test/message/source_map_throw_icu.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/icu');
8 changes: 0 additions & 8 deletions test/message/source_map_throw_icu.out
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,3 @@
Error: an error
at *icu.jsx:3:23*
at *icu.jsx:9:5*
at Module._compile (node:internal/modules/cjs/loader:*
at Object.Module._extensions..js (node:internal/modules/cjs/loader:*
at Module.load (node:internal/modules/cjs/loader:*
at Function.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_icu.js:*
at Module._compile (node:internal/modules/cjs/loader:*
Loading