Skip to content

Commit e0082e3

Browse files
Aayush Pratap Singhaayushprsingh
authored andcommitted
fix: add _readableState.ended to net.Socket stub for ssh2 compatibility
Fixes #71 ssh2's isWritable() checks stream._readableState.ended === false. Since the bridged net.Socket _readableState stub was missing the 'ended' property, ssh2 treated all sockets as non-writable and never sent handshake packets.
1 parent 5694e18 commit e0082e3

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/nodejs/src/bridge/network.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,7 @@ class DirectTunnelSocket {
19911991
private _listeners: Record<string, EventListener[]> = {};
19921992
private _encoding?: BufferEncoding;
19931993
private _peer: DirectTunnelSocket | null = null;
1994-
_readableState = { endEmitted: false };
1994+
_readableState = { endEmitted: false, ended: false };
19951995
_writableState = { finished: false, errorEmitted: false };
19961996

19971997
constructor(options?: { host?: string; port?: number }) {
@@ -4988,7 +4988,7 @@ class UpgradeSocket {
49884988
private _socketId: number;
49894989

49904990
// Readable stream state stub for ws compatibility (socketOnClose checks _readableState.endEmitted)
4991-
_readableState = { endEmitted: false };
4991+
_readableState = { endEmitted: false, ended: false };
49924992
_writableState = { finished: false, errorEmitted: false };
49934993

49944994
constructor(socketId: number, options?: { host?: string; port?: number }) {
@@ -8651,7 +8651,7 @@ class NetSocket {
86518651
_tlsSession: Buffer | null = null;
86528652
_tlsSessionReused = false;
86538653
// Readable stream state stub for library compatibility
8654-
_readableState = { endEmitted: false };
8654+
_readableState = { endEmitted: false, ended: false };
86558655
_handle: NetSocketHandle | null = null;
86568656

86578657
constructor(options?: { allowHalfOpen?: boolean; handle?: NetSocketHandle | null }) {

0 commit comments

Comments
 (0)