1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const { Worker } = require('worker_threads'); 5 6const w = new Worker( 7 `const fn = (err) => { 8 if (err.message === 'fhqwhgads') 9 throw new Error('come on'); 10 return 'This is my custom stack trace!'; 11 }; 12 Error.prepareStackTrace = fn; 13 throw new Error('fhqwhgads'); 14 `, 15 { eval: true } 16); 17w.on('message', common.mustNotCall()); 18w.on('error', common.mustCall((err) => { 19 assert.strictEqual(err.stack, undefined); 20 assert.strictEqual(err.message, 'fhqwhgads'); 21 assert.strictEqual(err.name, 'Error'); 22})); 23