mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 07:19:19 +00:00

worker is stable in the master branch. The flag is no longer required. PR-URL: https://github.com/nodejs/node/pull/31563 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
18 lines
591 B
JavaScript
18 lines
591 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { Worker, parentPort } = require('worker_threads');
|
|
const fs = require('fs');
|
|
|
|
// Checks that terminating Workers does not crash the process if fs.watchFile()
|
|
// has active handles.
|
|
|
|
// 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 worker = new Worker(__filename);
|
|
worker.on('message', common.mustCall(() => worker.terminate()));
|
|
} else {
|
|
fs.watchFile(__filename, () => {});
|
|
parentPort.postMessage('running');
|
|
}
|