From 8d0913bf95d113b3206df4565c3d63cfc40546fe Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Fri, 25 Aug 2023 14:16:35 +0100 Subject: [PATCH] net: use asserts in JS Socket Stream to catch races in future PR-URL: https://github.com/nodejs/node/pull/49400 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca --- lib/internal/js_stream_socket.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/js_stream_socket.js b/lib/internal/js_stream_socket.js index 68e1802a63b012..70d6d03069f3f1 100644 --- a/lib/internal/js_stream_socket.js +++ b/lib/internal/js_stream_socket.js @@ -149,6 +149,7 @@ class JSStreamSocket extends Socket { } const handle = this._handle; + assert(handle !== null); process.nextTick(() => { // Ensure that write is dispatched asynchronously. @@ -181,6 +182,8 @@ class JSStreamSocket extends Socket { } const handle = this._handle; + assert(handle !== null); + const self = this; let pending = bufs.length;