-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: serialize errors if stack getter throws
Current code that is intended to handle the stack getter throwing is untested. Add a test and adjust code to function as expected. Co-authored-by: Anna Henningsen <anna@addaleax.net> PR-URL: #26145 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
const w = new Worker( | ||
`const fn = (err) => { | ||
if (err.message === 'fhqwhgads') | ||
throw new Error('come on'); | ||
return 'This is my custom stack trace!'; | ||
}; | ||
Error.prepareStackTrace = fn; | ||
throw new Error('fhqwhgads'); | ||
`, | ||
{ eval: true } | ||
); | ||
w.on('message', common.mustNotCall()); | ||
w.on('error', common.mustCall((err) => { | ||
assert.strictEqual(err.stack, undefined); | ||
assert.strictEqual(err.message, 'fhqwhgads'); | ||
assert.strictEqual(err.name, 'Error'); | ||
})); |