Already buffered data when creating a TLSSocket doesn't trigger/throw 'error' #1114
Closed
Description
Brought over from nodejs/node-v0.x-archive#9355
If you pass a socket with already buffered data to TLSSocket and there's an error like:
[Error: 139745410942944:error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher:s3_srvr.c:1352]
It will fire as a _tlsError
immediately while in the constructor instead of either throwing an error (if there were no error handlers) or waiting till the next tick to fire the _tlsError
.
This can be solved by wrapping this._init(socket)
in a process.nextTick
or delaying:
// Socket already has some buffered data - emulate receiving it
if (socket && socket._readableState.length) {
var buf;
while ((buf = socket.read()) !== null)
this.ssl.receive(buf);
}
It seems like the second option (delaying the initial buffer read) is better but let me know what you guys think.
Activity