Skip to content

Commit ea42514

Browse files
addaleaxtargos
authored andcommitted
test: add fs.watchFile() + worker.terminate() test
Refs: #21093 (comment) PR-URL: #21179 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 0303aba commit ea42514

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Flags: --experimental-worker
2+
'use strict';
3+
const common = require('../common');
4+
const { Worker, parentPort } = require('worker_threads');
5+
const fs = require('fs');
6+
7+
// Checks that terminating Workers does not crash the process if fs.watchFile()
8+
// has active handles.
9+
10+
// Do not use isMainThread so that this test itself can be run inside a Worker.
11+
if (!process.env.HAS_STARTED_WORKER) {
12+
process.env.HAS_STARTED_WORKER = 1;
13+
const worker = new Worker(__filename);
14+
worker.on('message', common.mustCall(() => worker.terminate()));
15+
} else {
16+
fs.watchFile(__filename, () => {});
17+
parentPort.postMessage('running');
18+
}

0 commit comments

Comments
 (0)