blob: dddf91e3f39a6bb52a1428dc4268da1fa2c886d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
'use strict';
require('../common');
const { Worker, MessageChannel } = require('worker_threads');
// Check the interaction of calling .terminate() while transferring
// MessagePort objects; in particular, that it does not crash the process.
for (let i = 0; i < 10; ++i) {
const w = new Worker(
"require('worker_threads').parentPort.on('message', () => {})",
{ eval: true });
setImmediate(() => {
const port = new MessageChannel().port1;
w.postMessage({ port }, [ port ]);
w.terminate();
});
}
|