1'use strict'; 2const common = require('../common'); 3 4const { MessageChannel } = require('worker_threads'); 5 6// Make sure that closing a message port while receiving messages on it does 7// not stop messages that are already in the queue from being emitted. 8 9const { port1, port2 } = new MessageChannel(); 10 11port1.on('message', common.mustCall(() => { 12 port1.close(); 13}, 2)); 14port2.postMessage('foo'); 15port2.postMessage('bar'); 16