-
Notifications
You must be signed in to change notification settings - Fork 7.3k
HTTPS connection failing because socket has been deleted #9348
Comments
The error seems to be originating from
I don't think that |
The relevant code in npm uses a custom |
Well, if the |
I'm trying, over on npm/npm#7349. ;) At this point we know about the same amount about what's going on. I'm also away from my computer, so I can't bang on this myself until tonight. |
Test case: var net = require('net');
var http = require('http');
var util = require('util');
function Agent() {
http.Agent.call(this);
}
util.inherits(Agent, http.Agent);
Agent.prototype.createConnection = function() {
var self = this;
var socket = new net.Socket();
socket.on('error', function() {
socket.push('OH GOSH');
});
socket.on('newListener', function onNewListener(name) {
if (name !== 'error')
return;
socket.removeListener('newListener', onNewListener);
// Let other listeners to be set up too
process.nextTick(function() {
self.breakSocket(socket);
});
});
return socket;
};
Agent.prototype.breakSocket = function breakSocket(socket) {
socket.emit('error', new Error('Intentional error'));
};
var agent = new Agent();
http.request({
agent: agent
}).once('error', function() {
console.log('ignore');
}); |
Patch is coming soon. |
Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: nodejs/node-v0.x-archive#9348
Suggested fix https://github.com/iojs/io.js/pull/1103/files |
Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: nodejs/node-v0.x-archive#9348 PR-URL: #1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
The fix has been landed in io.js: nodejs/node@1a3ca82, please backport |
Notable changes: * tls: The reported TLS memory leak has been at least partially resolved via various commits in this release. Current testing indicated that there may still be some leak problems. Progress being tracked at: #1075 * http: Fixed an error reported at nodejs/node-v0.x-archive#9348 and npm/npm#7349 Pending data was not being fully read upon an 'error' event leading to an assertion failure on socket.destroy(). (Fedor Indutny) #1103
Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: nodejs#9348 PR-URL: nodejs/node#1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
Thank you very much @indutny! nodejs/node@1a3ca82 LGTM, and I would land it. However, I just want to wait for a while to see if we get any feedback on npm/npm#7349 (comment) before landing it as a fix for this issue. |
Just for the record, this issue is fixed by nodejs/node@1a3ca82, see npm/npm#7349 (comment). |
This change is a backport of 1a3ca82 from io.js. Original commit message: Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: nodejs#9348 PR-URL: nodejs/node#1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com> Fixes nodejs#9348.
This change is a backport of 1a3ca82 from io.js. Original commit message: Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: nodejs#9348 PR-URL: nodejs/node#1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com> Fixes nodejs#9348.
This change is a backport of 1a3ca82 from io.js. Original commit message: Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: #9348 PR-URL: nodejs/node#1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com> Fixes #9348. Reviewed-By: Julien Gilli <julien.gilli@joyent.com> PR-URL: #14087
Here are two stacktraces that I have collected within the last few hours from two separate npm users. This failure has been seen on all of OS X, Windows, and Linux.:
See also npm/npm#7349 for more discussion and further links to people encountering this issue, which ultimately traces back to this bare assert in
_http_client.js
. It's rare enough that it's probably a race condition, and I seem to recall a similar issue getting fixed elsewhere in the not too distant pass. @indutny? Anybody?The text was updated successfully, but these errors were encountered: