summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-error-stack-getter-throws.js
blob: 108fa3f5143d183ceb1b33ece788e259cd677139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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');
}));