Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b510cdc

Browse filesBrowse files
thefourtheyetargos
authored andcommitted
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>
1 parent 580071d commit b510cdc
Copy full SHA for b510cdc

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/worker_threads.md‎

Copy file name to clipboardExpand all lines: doc/api/worker_threads.md
+2-2Lines changed: 2 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ added: v10.5.0
377377
* `transferList` {Object[]}
378378

379379
Send a message to the worker that will be received via
380-
[`require('worker_threads').on('message')`][].
380+
[`require('worker_threads').parentPort.on('message')`][].
381381
See [`port.postMessage()`][] for more details.
382382

383383
### worker.ref()
@@ -480,7 +480,7 @@ active handle in the event system. If the worker is already `unref()`ed calling
480480
[`process.stdout`]: process.html#process_process_stdout
481481
[`process.title`]: process.html#process_process_title
482482
[`require('worker_threads').workerData`]: #worker_threads_worker_workerdata
483-
[`require('worker_threads').on('message')`]: #worker_threads_event_message_1
483+
[`require('worker_threads').parentPort.on('message')`]: #worker_threads_event_message
484484
[`require('worker_threads').postMessage()`]: #worker_threads_worker_postmessage_value_transferlist
485485
[`require('worker_threads').isMainThread`]: #worker_threads_worker_ismainthread
486486
[`require('worker_threads').parentPort`]: #worker_threads_worker_parentport

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.