-
- Notifications
You must be signed in to change notification settings - Fork 33.7k
doc: fix worker example to receive message #21486
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
Closed
Closed
Conversation
This file contains hidden or 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
Collaborator
TimothyGu approved these changes Jun 23, 2018
doc/api/worker_threads.md Outdated
Member
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
Member
| @thefourtheye Can you rebase this? |
Member
| ping @thefourtheye |
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`. 9bc522d to d1b0121 Compare Contributor Author
cjihrig approved these changes Jul 17, 2018
addaleax approved these changes Jul 18, 2018
Member
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> Member
| Landed in 42be4c3 🎉 |
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. Sooncemethod would not be in it. The correct way to receive the messagewould be to attach a listener to the
messageevent on theparentPort.Also, there is no built-in event called
workerMessage. This patchfixes it by referencing
messageevent.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes