summaryrefslogtreecommitdiff
path: root/test/parallel/test-worker-fs-stat-watcher.js
blob: b58d43d0cfa8ea5b52e22b304df8ef84c283323a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Flags: --experimental-worker
'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');
}