Skip to content

Commit

Permalink
test: remove cjs loader from stack traces
Browse files Browse the repository at this point in the history
PR-URL: #44197
Backport-PR-URL: #46535
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
GeoffreyBooth authored and BethGriggs committed Mar 27, 2023
1 parent cf76d07 commit fc47d58
Show file tree
Hide file tree
Showing 47 changed files with 50 additions and 216 deletions.
2 changes: 2 additions & 0 deletions test/message/core_line_numbers.js
@@ -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
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
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
@@ -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
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
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
@@ -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
@@ -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
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
@@ -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
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
@@ -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
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
@@ -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
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
@@ -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
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
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
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
@@ -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
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
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
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
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
@@ -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
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
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
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
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
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
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
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
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:*

0 comments on commit fc47d58

Please sign in to comment.