node/test/parallel/test-worker-abort-on-uncaught-exception-terminate.js
Anna Henningsen 85b95cc6a3
worker: ignore --abort-on-uncaught-exception for terminate()
When running Worker threads with `--abort-on-uncaught-exception`,
do not abort the process when `worker.terminate()` is called.

PR-URL: https://github.com/nodejs/node/pull/26111
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-02-18 09:17:11 +01:00

13 lines
440 B
JavaScript

// Flags: --abort-on-uncaught-exception
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
// Tests that --abort-on-uncaught-exception does not apply to
// termination exceptions.
const w = new Worker('while(true);', { eval: true });
w.on('online', common.mustCall(() => w.terminate()));
w.on('exit', common.mustCall((code) => assert.strictEqual(code, 1)));