★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/21486Nouvelle recherche | Portail wanayoo
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

doc: fix worker example to receive message #21486

Closed

Conversation

Projects
None yet
10 participants
@thefourtheye
Copy link
Contributor

thefourtheye commented Jun 23, 2018 •

require('worker_threads') is not an instance of EventEmitter. So
once 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.

Also, there is no built-in event called workerMessage. This patch
fixes it by referencing message event.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@thefourtheye thefourtheye requested a review from addaleax Jun 23, 2018

@@ -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')`][].

This comment has been minimized.

@TimothyGu

TimothyGu Jun 23, 2018

Member

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.
@vssenko

This comment has been minimized.

Copy link

vssenko commented Jun 29, 2018

Wow, luckly i found this issue, helped a lot. But documentation is still invalid.

@TimothyGu TimothyGu referenced this pull request Jul 9, 2018

Closed

tools: add no-duplicate-requires rule #21712

2 of 2 tasks complete
@addaleax

This comment has been minimized.

Copy link
Member

addaleax commented Jul 9, 2018

@thefourtheye Can you rebase this?

@jasnell

This comment has been minimized.

Copy link
Member

jasnell commented Jul 12, 2018

@thefourtheye thefourtheye force-pushed the thefourtheye:fix-worker-threads-doc branch from f80beff to 9bc522d Jul 17, 2018

doc: fix worker example to receive message
`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 thefourtheye force-pushed the thefourtheye:fix-worker-threads-doc branch from 9bc522d to d1b0121 Jul 17, 2018

@thefourtheye

This comment has been minimized.

Copy link
Contributor Author

thefourtheye commented Jul 17, 2018

@addaleax @jasnell Sorry for the delay. Rebased the PR now.

@addaleax

This comment has been minimized.

BridgeAR added a commit to BridgeAR/node that referenced this pull request Jul 18, 2018

doc: fix worker example to receive message
`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>
@BridgeAR

This comment has been minimized.

Copy link
Member

BridgeAR commented Jul 18, 2018

Landed in 42be4c3 🎉

@BridgeAR BridgeAR closed this Jul 18, 2018

@thefourtheye thefourtheye deleted the thefourtheye:fix-worker-threads-doc branch Jul 18, 2018

@targos targos removed the author ready label Jul 19, 2018

targos added a commit that referenced this pull request Jul 19, 2018

doc: fix worker example to receive message
`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>

@targos targos referenced this pull request Jul 31, 2018

Merged

v10.8.0 proposal #22040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.