@@ -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 |
+} |