mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
79a3348d14
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: https://github.com/nodejs/node/pull/26145 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
23 lines
607 B
JavaScript
23 lines
607 B
JavaScript
'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');
|
|
}));
|