Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain (most of) Node.js internals in stack traces
This retains most of the Node.js internals in stack traces for the mini and verbose reporters. Internals are dimmed in the output. Call sites are prefixed with a small pointer. Reporter logs are now tested for each Node.js version separately. Stack beautification now takes place in the main process, not the workers. Fixes #2110. Co-authored-by: Mark Wubben <mark@novemberborn.net>
- Loading branch information
1 parent
3c0fc03
commit 9a9351d
Showing
77 changed files
with
3,633 additions
and
370 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
const StackUtils = require('stack-utils'); | ||
|
||
const stackUtils = new StackUtils({ | ||
ignoredPackages: [ | ||
'@ava/babel', | ||
'@ava/require-precompiled', | ||
'@ava/typescript', | ||
'append-transform', | ||
'ava', | ||
'empower-core', | ||
'esm', | ||
'nyc' | ||
], | ||
internals: [ | ||
// AVA internals, which ignoredPackages don't ignore when we run our own unit tests. | ||
/\/ava\/(?:lib\/|lib\/worker\/)?[\w-]+\.js:\d+:\d+\)?$/, | ||
// Only ignore Node.js internals that really are not useful for debugging. | ||
...StackUtils.nodeInternals().filter(regexp => !/\(internal/.test(regexp.source)), | ||
/\(internal\/process\/task_queues\.js:\d+:\d+\)$/, | ||
/\(internal\/modules\/cjs\/.+?\.js:\d+:\d+\)$/, | ||
/async Promise\.all \(index/, | ||
/new Promise \(<anonymous>\)/ | ||
] | ||
}); | ||
|
||
/* | ||
* Given a string value of the format generated for the `stack` property of a | ||
* V8 error object, return a string that contains only stack frame information | ||
* for frames that have relevance to the consumer. | ||
* | ||
* For example, given the following string value: | ||
* | ||
* ``` | ||
* Error | ||
* at inner (/home/ava/ex.js:7:12) | ||
* at /home/ava/ex.js:12:5 | ||
* at outer (/home/ava/ex.js:13:4) | ||
* at Object.<anonymous> (/home/ava/ex.js:14:3) | ||
* at Module._compile (module.js:570:32) | ||
* at Object.Module._extensions..js (module.js:579:10) | ||
* at Module.load (module.js:487:32) | ||
* at tryModuleLoad (module.js:446:12) | ||
* at Function.Module._load (module.js:438:3) | ||
* at Module.runMain (module.js:604:10) | ||
* ``` | ||
* | ||
* ...this function returns the following string value: | ||
* | ||
* ``` | ||
* inner (/home/ava/ex.js:7:12) | ||
* /home/ava/ex.js:12:5 | ||
* outer (/home/ava/ex.js:13:4) | ||
* Object.<anonymous> (/home/ava/ex.js:14:3) | ||
* Module._compile (module.js:570:32) | ||
* Object.Module._extensions..js (module.js:579:10) | ||
* Module.load (module.js:487:32) | ||
* tryModuleLoad (module.js:446:12) | ||
* Function.Module._load (module.js:438:3) | ||
* Module.runMain (module.js:604:10) | ||
* ``` | ||
*/ | ||
module.exports = stack => { | ||
if (!stack) { | ||
return []; | ||
} | ||
|
||
return stackUtils.clean(stack).trim().split('\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.