Assertion failed for conn.end() in old mode #4997

Closed
algesten opened this Issue Mar 13, 2013 · 3 comments

4 participants

@algesten

I consistently get this error with node.js 0.10.0

Assertion failed: (uv__stream_fd(stream) >= 0), function uv_shutdown, file ../deps/uv/src/unix/stream.c, line 1084.
Abort trap: 6

Here's my test code:

var conn = require('net').createConnection(80,'nowhere');

// kick into old mode
conn.addListener('data', function(data) {
});

// watch it blow
conn.end();
princess$ node -v
v0.10.0

Mac OS X 10.8.2. Node installed by brew.

@bnoordhuis
Node.js Foundation member

Confirmed. lib/net.js calls uv_shutdown() before uv_connect() has finished. v0.8 handles this correctly by deferring the shutdown until the afterConnect callback is invoked.

@isaacs It's a streams2 regression and - like all things stream2 - I'm not sure how to fix it. This patch seems to fix it with no ill effects:

diff --git a/lib/net.js b/lib/net.js
index b994c27..d0d6af2 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -190,6 +190,11 @@ function onSocketFinish() {
     return this.destroy();
   }

+  if (this._connecting) {
+    debug('onSocketEnd: still connecting');
+    return;
+  }
+
   debug('oSF: not ended, call shutdown()');

   // otherwise, just shutdown, or destroy() if not possible
@indutny
Node.js Foundation member

I'm afraid this fix is't going to work properly, I'll make another one if you don't mind.

@isaacs

Fixed by #5001

@isaacs isaacs closed this Mar 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment