mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 13:28:42 +00:00

An empty `Local<>` already indicates that an exception is pending, so there is no need to throw an exception. In the case of Workers, this could override a `.terminate()` call. PR-URL: https://github.com/nodejs/node/pull/26112 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
20 lines
605 B
JavaScript
20 lines
605 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const vm = require('vm');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Do not use isMainThread so that this test itself can be run inside a Worker.
|
|
if (!process.env.HAS_STARTED_WORKER) {
|
|
process.env.HAS_STARTED_WORKER = 1;
|
|
const w = new Worker(__filename);
|
|
w.on('online', common.mustCall(() => {
|
|
setTimeout(() => w.terminate(), 50);
|
|
}));
|
|
w.on('error', common.mustNotCall());
|
|
w.on('exit', common.mustCall((code) => assert.strictEqual(code, 1)));
|
|
} else {
|
|
while (true)
|
|
vm.runInNewContext('');
|
|
}
|