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