xref: /third_party/node/test/parallel/test-worker-error-stack-getter-throws.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst w = new Worker(
71cb0ef41Sopenharmony_ci  `const fn = (err) => {
81cb0ef41Sopenharmony_ci    if (err.message === 'fhqwhgads')
91cb0ef41Sopenharmony_ci      throw new Error('come on');
101cb0ef41Sopenharmony_ci    return 'This is my custom stack trace!';
111cb0ef41Sopenharmony_ci  };
121cb0ef41Sopenharmony_ci  Error.prepareStackTrace = fn;
131cb0ef41Sopenharmony_ci  throw new Error('fhqwhgads');
141cb0ef41Sopenharmony_ci  `,
151cb0ef41Sopenharmony_ci  { eval: true }
161cb0ef41Sopenharmony_ci);
171cb0ef41Sopenharmony_ciw.on('message', common.mustNotCall());
181cb0ef41Sopenharmony_ciw.on('error', common.mustCall((err) => {
191cb0ef41Sopenharmony_ci  assert.strictEqual(err.stack, undefined);
201cb0ef41Sopenharmony_ci  assert.strictEqual(err.message, 'fhqwhgads');
211cb0ef41Sopenharmony_ci  assert.strictEqual(err.name, 'Error');
221cb0ef41Sopenharmony_ci}));
23

Indexes created Thu Nov 07 10:32:03 CST 2024