From 9ccf8b2ccc1b650ba0f9749e2ffe2780e51d1000 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 29 Sep 2022 20:55:17 +0200 Subject: [PATCH] lib: use process.nextTick() instead of setImmediate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not delay the call to `stream.end()` too much. PR-URL: https://github.com/nodejs/node/pull/42340 Refs: https://github.com/nodejs/node/pull/42340#issuecomment-1261163284 Reviewed-By: Michaël Zasso Reviewed-By: Juan José Arboleda Reviewed-By: Yagiz Nizipli Reviewed-By: Darshan Sen Reviewed-By: Antoine du Hamel --- lib/internal/js_stream_socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index f2a0ecaa1d8a65..f1efa1f807cb9a 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -141,7 +141,7 @@ class JSStreamSocket extends Socket { const handle = this._handle; - setImmediate(() => { + process.nextTick(() => { // Ensure that write is dispatched asynchronously. this.stream.end(() => { this.finishShutdown(handle, 0);