test: add fs.watchFile() + worker.terminate() test
Refs: https://github.com/nodejs/node/pull/21093#discussion_r193563156 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
3a9592496c
commit
d398e8988c
18
test/parallel/test-worker-fs-stat-watcher.js
Normal file
18
test/parallel/test-worker-fs-stat-watcher.js
Normal file
@ -0,0 +1,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');
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user