Skip to content

Commit aa9a86a

Browse files
committedJan 23, 2019
test,worker: verify that .terminate() breaks microtask queue
PR-URL: #25480 Reviewed-By: James M Snell <[email protected]>
1 parent d6b50c6 commit aa9a86a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
Please sign in to comment.