Commit Graph

2 Commits

Author SHA1 Message Date
Anna Henningsen
d7c5ffc7a4
test: improve test-worker-message-port-message-before-close
Replace a wrong comment with a correct assertion and await all async
operations inside the async function.

PR-URL: https://github.com/nodejs/node/pull/29483
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-09-09 22:19:42 +02:00
Anna Henningsen
6019060cbb
worker: use special message as MessagePort close command
When a `MessagePort` connected to another `MessagePort` closes, the
latter `MessagePort` will be closed as well. Until now, this is done
by testing whether the ports are still entangled after processing
messages. This leaves open a race condition window in which messages
sent just before the closure can be lost when timing is unfortunate.
(A description of the timing is in the test file.)

This can be addressed by using a special message instead, which is
the last message received by a `MessagePort`. This way, all previously
sent messages are processed first.

Fixes: https://github.com/nodejs/node/issues/22762
PR-URL: https://github.com/nodejs/node/pull/27705
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-17 14:01:27 +02:00