Skip to content

Commit

Permalink
doc: clarify Worker exit/message event ordering
Browse files Browse the repository at this point in the history
Motivated by the fact that getting this wrong has led to flaky
tests in our test suite.

Refs: #31637

PR-URL: #31642
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and codebytere committed Mar 30, 2020
1 parent 5e68a13 commit 28657cc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,8 @@ exited by calling [`process.exit()`][], the `exitCode` parameter will be the
passed exit code. If the worker was terminated, the `exitCode` parameter will
be `1`.

This is the final event emitted by any `Worker` instance.

### Event: `'message'`
<!-- YAML
added: v10.5.0
Expand All @@ -593,6 +595,9 @@ The `'message'` event is emitted when the worker thread has invoked
[`require('worker_threads').parentPort.postMessage()`][].
See the [`port.on('message')`][] event for more details.

All messages sent from the worker thread will be emitted before the
[`'exit'` event][] is emitted on the `Worker` object.

### Event: `'online'`
<!-- YAML
added: v10.5.0
Expand Down

0 comments on commit 28657cc

Please sign in to comment.