Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timing of MessagePort entanglement transfer #5850

Open
karlt opened this issue Aug 21, 2020 · 0 comments
Open

Timing of MessagePort entanglement transfer #5850

karlt opened this issue Aug 21, 2020 · 0 comments

Comments

@karlt
Copy link

karlt commented Aug 21, 2020

Consider:

const mc = new MessageChannel;
const shipper = new MessageChannel;
shipper.port1.postMessage(null, [mc.port1]);
shipper.port1.postMessage(null, [mc.port2]);
let i = 0;
shipper.port2.onmessage = ({ports: [shipped]}) => {
  ++i;
  shipped.onmessage = e => console.log(e.data);
  shipped.postMessage(`message ${i}`);
};

I'd expect 'message 1' and 'message 2' to be logged. That's what happens in Firefox and Chrome, but that's not what the spec says.

IIUC the spec says the task for 'message 1' will be put in the port message queue of mc.port2 and then moved to the port message queue of the corresponding shipped port (in transfer-receiving steps) and logged. However, the task for 'message 2' will be put in the port message queue of mc.port1 and is not moved to another port message queue.

@gterzian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants