xref: /third_party/node/test/parallel/test-worker-non-fatal-uncaught-exception.js
  • 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_ci// Check that `process._fatalException()` returns a boolean when run inside a
71cb0ef41Sopenharmony_ci// worker.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// Do not use isMainThread so that this test itself can be run inside a Worker.
101cb0ef41Sopenharmony_ciif (!process.env.HAS_STARTED_WORKER) {
111cb0ef41Sopenharmony_ci  process.env.HAS_STARTED_WORKER = 1;
121cb0ef41Sopenharmony_ci  const w = new Worker(__filename);
131cb0ef41Sopenharmony_ci  w.on('exit', common.mustCall((code) => {
141cb0ef41Sopenharmony_ci    assert.strictEqual(code, 0);
151cb0ef41Sopenharmony_ci  }));
161cb0ef41Sopenharmony_ci  return;
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciprocess.once('uncaughtException', () => {
201cb0ef41Sopenharmony_ci  process.nextTick(() => {
211cb0ef41Sopenharmony_ci    assert.strictEqual(res, true);
221cb0ef41Sopenharmony_ci  });
231cb0ef41Sopenharmony_ci});
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconst res = process._fatalException(new Error());
26

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