From c3fdc994502cfb2f9a1274e78530a08609f5efb1 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 28 Jun 2021 11:16:11 +0200 Subject: [PATCH] [minor] Fix misleading comment --- lib/stream.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/stream.js b/lib/stream.js index 53706cc90..c3a793691 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -84,13 +84,13 @@ function createWebSocketStream(ws, options) { // Prevent `ws.terminate()` from being called by `duplex._destroy()`. // - // - If the state of the `WebSocket` connection is `CONNECTING`, - // `ws.terminate()` is a noop as no socket was assigned. - // - Otherwise, the error was re-emitted from the listener of the `'error'` + // - If the `'error'` event is emitted before the `'open'` event, then + // `ws.terminate()` is a noop as no socket is assigned. + // - Otherwise, the error is re-emitted by the listener of the `'error'` // event of the `Receiver` object. The listener already closes the // connection by calling `ws.close()`. This allows a close frame to be // sent to the other peer. If `ws.terminate()` is called right after this, - // the close frame might not be sent. + // then the close frame might not be sent. terminateOnDestroy = false; duplex.destroy(err); });