From d1b01217369f58d2218d6cd38de33150d2854b16 Mon Sep 17 00:00:00 2001 From: "Sakthipriyan Vairamani (thefourtheye)" Date: Sat, 23 Jun 2018 17:10:10 +0530 Subject: [PATCH] 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`. --- doc/api/worker_threads.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index 8b301f42a87620..025a8c9a3ab2cf 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -377,7 +377,7 @@ added: v10.5.0 * `transferList` {Object[]} Send a message to the worker that will be received via -[`require('worker_threads').on('message')`][]. +[`require('worker_threads').parentPort.on('message')`][]. See [`port.postMessage()`][] for more details. ### worker.ref() @@ -480,7 +480,7 @@ active handle in the event system. If the worker is already `unref()`ed calling [`process.stdout`]: process.html#process_process_stdout [`process.title`]: process.html#process_process_title [`require('worker_threads').workerData`]: #worker_threads_worker_workerdata -[`require('worker_threads').on('message')`]: #worker_threads_event_message_1 +[`require('worker_threads').parentPort.on('message')`]: #worker_threads_event_message [`require('worker_threads').postMessage()`]: #worker_threads_worker_postmessage_value_transferlist [`require('worker_threads').isMainThread`]: #worker_threads_worker_ismainthread [`require('worker_threads').parentPort`]: #worker_threads_worker_parentport