Skip to content

Commit 77d1f4a

Browse files
committed
tls: set _connecting before starting the flow
When creating a TLSSocket instance based on the existing connecting socket, `_connecting` property is copied after the initialization of `net.Socket`. However, since `net.Socket` constructor will call `.read(0)` if the `readable` is true - error may happen at this code chunk in net.js: Socket.prototype._read = function(n) { debug('_read'); if (this._connecting || !this._handle) { debug('_read wait for connection'); this.once('connect', this._read.bind(this, n)); ... Leading to a test failures on windows: - test/simple/test-tls-connect-given-socket.js Signed-off-by: Fedor Indutny <[email protected]>
1 parent 2c6b424 commit 77d1f4a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/_tls_wrap.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ function TLSSocket(socket, options) {
177177
net.Socket.call(this, {
178178
handle: socket && socket._handle,
179179
allowHalfOpen: socket && socket.allowHalfOpen,
180-
readable: true,
181-
writable: true
180+
readable: false,
181+
writable: false
182182
});
183183

184184
// To prevent assertion in afterConnect()
@@ -210,6 +210,12 @@ function TLSSocket(socket, options) {
210210
} else {
211211
this._init(socket);
212212
}
213+
214+
// Make sure to setup all required properties like: `_connecting` before
215+
// starting the flow of the data
216+
this.readable = true;
217+
this.writable = true;
218+
this.read(0);
213219
}
214220
util.inherits(TLSSocket, net.Socket);
215221
exports.TLSSocket = TLSSocket;

0 commit comments

Comments
 (0)