Skip to content

Commit c3fdc99

Browse files
committed
[minor] Fix misleading comment
1 parent 145480a commit c3fdc99

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/stream.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ function createWebSocketStream(ws, options) {
8484

8585
// Prevent `ws.terminate()` from being called by `duplex._destroy()`.
8686
//
87-
// - If the state of the `WebSocket` connection is `CONNECTING`,
88-
// `ws.terminate()` is a noop as no socket was assigned.
89-
// - Otherwise, the error was re-emitted from the listener of the `'error'`
87+
// - If the `'error'` event is emitted before the `'open'` event, then
88+
// `ws.terminate()` is a noop as no socket is assigned.
89+
// - Otherwise, the error is re-emitted by the listener of the `'error'`
9090
// event of the `Receiver` object. The listener already closes the
9191
// connection by calling `ws.close()`. This allows a close frame to be
9292
// sent to the other peer. If `ws.terminate()` is called right after this,
93-
// the close frame might not be sent.
93+
// then the close frame might not be sent.
9494
terminateOnDestroy = false;
9595
duplex.destroy(err);
9696
});

0 commit comments

Comments
 (0)