-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: fix worker example to receive message #21486
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thefourtheye
added
doc
Issues and PRs related to the documentations.
worker
Issues and PRs related to Worker support.
labels
Jun 23, 2018
TimothyGu
approved these changes
Jun 23, 2018
doc/api/worker_threads.md
Outdated
@@ -375,7 +376,7 @@ added: v10.5.0 | |||
* `transferList` {Object[]} | |||
|
|||
Send a message to the worker that will be received via | |||
[`require('worker_threads').on('workerMessage')`][]. | |||
[`require('worker_threads').parentPort.on('message')`][]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case the norm is to link worker_threads.parentPort
and 'message'
separately, to something like
received via [`worker_threads.parentPort`][]'s [`'message'`][`port.on('message')`] event.
vsemozhetbyt
approved these changes
Jun 23, 2018
jasnell
approved these changes
Jun 24, 2018
Wow, luckly i found this issue, helped a lot. But documentation is still invalid. |
2 tasks
@thefourtheye Can you rebase this? |
ping @thefourtheye |
thefourtheye
force-pushed
the
fix-worker-threads-doc
branch
from
July 17, 2018 04:46
f80beff
to
9bc522d
Compare
`require('worker_threads')` is not an instance of `EventEmitter`. So `on` method would not be in it. The correct way to receive the message would be to attach a listener to the `message` event on the `parentPort`.
thefourtheye
force-pushed
the
fix-worker-threads-doc
branch
from
July 17, 2018 04:50
9bc522d
to
d1b0121
Compare
cjihrig
approved these changes
Jul 17, 2018
addaleax
approved these changes
Jul 18, 2018
addaleax
added
the
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
label
Jul 18, 2018
BridgeAR
approved these changes
Jul 18, 2018
BridgeAR
pushed a commit
to BridgeAR/node
that referenced
this pull request
Jul 18, 2018
`require('worker_threads')` is not an instance of `EventEmitter`. So `on` method would not be in it. The correct way to receive the message would be to attach a listener to the `message` event on the `parentPort`. PR-URL: nodejs#21486 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Landed in 42be4c3 🎉 |
targos
removed
the
author ready
PRs that have at least one approval, no pending requests for changes, and a CI started.
label
Jul 19, 2018
targos
pushed a commit
that referenced
this pull request
Jul 19, 2018
`require('worker_threads')` is not an instance of `EventEmitter`. So `on` method would not be in it. The correct way to receive the message would be to attach a listener to the `message` event on the `parentPort`. PR-URL: #21486 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Merged
This was referenced Aug 1, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
require('worker_threads')
is not an instance ofEventEmitter
. Soonce
method would not be in it. The correct way to receive the messagewould be to attach a listener to the
message
event on theparentPort
.Also, there is no built-in event called
workerMessage
. This patchfixes it by referencing
message
event.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes