Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardNodeJSworker_threads memory sharingSingle-choice MCQ

A MessagePort is itself placed in the transferList of a postMessage to a worker, alongside ordinary data. What happens to that MessagePort in the sending thread, and what makes ports special compared to transferring an ArrayBuffer?

const { port1, port2 } = new MessageChannel(); worker.postMessage({ control: port1 }, [port1]); // can the main thread still use port1 afterward?