8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
.terminate()
1 parent d6b50c6 commit aa9a86aCopy full SHA for aa9a86a
test/parallel/test-worker-terminate-microtask-loop.js
@@ -0,0 +1,19 @@
1
+'use strict';
2
+const common = require('../common');
3
+const assert = require('assert');
4
+const { Worker } = require('worker_threads');
5
+
6
+// Verify that `.terminate()` interrupts the microtask queue.
7
8
+const worker = new Worker(`
9
+function loop() { Promise.resolve().then(loop); } loop();
10
+require('worker_threads').parentPort.postMessage('up');
11
+`, { eval: true });
12
13
+worker.once('message', common.mustCall(() => {
14
+ setImmediate(() => worker.terminate());
15
+}));
16
17
+worker.once('exit', common.mustCall((code) => {
18
+ assert.strictEqual(code, 1);
19
0 commit comments