From 9c5db9375fe63810906d1ed03493e2e280fe62f8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 2 Jan 2019 16:07:20 +0100 Subject: [PATCH] worker: improve JS-side debugging Do not print debug messages that indicate that a stdio stream has drained; because `util.debuglog()` uses `console.log`, which in turn uses stdio streams, this would otherwise have lead to an endless loop. PR-URL: https://github.com/nodejs/node/pull/25312 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- lib/internal/worker/io.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js index d249ba8508b7af..ad8056b5b9108a 100644 --- a/lib/internal/worker/io.js +++ b/lib/internal/worker/io.js @@ -62,7 +62,8 @@ MessagePort.prototype.unref = MessagePortPrototype.unref; // .onmessage events, and a function used for sending data to a MessagePort // in some other thread. MessagePort.prototype[kOnMessageListener] = function onmessage(payload) { - debug(`[${threadId}] received message`, payload); + if (payload.type !== messageTypes.STDIO_WANTS_MORE_DATA) + debug(`[${threadId}] received message`, payload); // Emit the deserialized object to userland. this.emit('message', payload); };