• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const { Worker, parentPort } = require('worker_threads');
4const fs = require('fs');
5
6// Checks that terminating Workers does not crash the process if fs.watchFile()
7// has active handles.
8
9// Do not use isMainThread so that this test itself can be run inside a Worker.
10if (!process.env.HAS_STARTED_WORKER) {
11  process.env.HAS_STARTED_WORKER = 1;
12  const worker = new Worker(__filename);
13  worker.on('message', common.mustCall(() => worker.terminate()));
14} else {
15  fs.watchFile(__filename, () => {});
16  parentPort.postMessage('running');
17}
18