Re: [nodejs] Socket hang up problems [PATCH]

388 views
Skip to first unread message

Michael Stillwell

unread,
Mar 10, 2011, 6:44:22 PM3/10/11
to nod...@googlegroups.com
On Tue, Mar 8, 2011 at 9:14 PM, Ryan Dahl <r...@tinyclouds.org> wrote:
> On Tue, Mar 1, 2011 at 5:31 AM, easternbloc <madma...@gmail.com> wrote:
>> Hi,
>>
>> I've been getting this issue every now and then on a long poll
>> request.
>> It doesn't happen consistently so I'm finding it very hard to track
>> down.
>> Has anyone else had this error?
>>
>> node.js:116
>>        throw e; // process.nextTick error, or 'error' event on first
>> tick
>>        ^
>> Error: socket hang up
>>    at Client.<anonymous> (http.js:1440:26)
>>    at Client.emit (events.js:42:17)
>>    at Array.<anonymous> (net.js:800:12)
>>    at EventEmitter._tickCallback (node.js:108:26)
>>
>> Any help would be greatly appreciated.
>>
>
> It's a bug - but we need to get a reproducible test case.

I'm not sure if this is the same bug, but the http.get() at

https://gist.github.com/865171

throws an exception if you wait a few seconds. (The server eventually
returns "ECONNRESET, Connection reset by peer.")

There's a patch at

https://gist.github.com/865174

which basically removes some of the error handling code that seems to
be bogus--the existing http code seemed expect to find some sort of
in-flight request in the request queue on socket error, but it seems
to me that it's possible for there to be no such request. (The
requests may have already been satisfied by other sockets, for
example.)

I haven't written any tests because I'm not sure how to simulate the
ECONNRESET--is there some way to do this?

Michael

--
http://beebo.org

Charlie Robbins

unread,
Mar 10, 2011, 11:00:57 PM3/10/11
to nod...@googlegroups.com, nodej...@googlegroups.com, Michael Stillwell
Adding nodejs-dev list; seemed appropriate.

Do all of the functional / pummel tests pass with this patch? 

It seems like this patch would fix another issue that I've seen recently working on updating node-http-proxy to use the http.Agent APIs:

node.js:116
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Cannot call method 'emit' of undefined
    at Socket.<anonymous> (http.js:1174:9)
    at Socket.emit (events.js:42:17)
    at Array.<anonymous> (net.js:799:27)
    at EventEmitter._tickCallback (node.js:108:26)



--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Michael Stillwell

unread,
Mar 11, 2011, 3:01:00 AM3/11/11
to nodej...@googlegroups.com, nod...@googlegroups.com
There was one test that failed (test-http-agent2.js:61), but it failed
before the patch as well. (This is with master on OS X--is that
supposed to happen?) As I say I'd like to write a test for the patch,
but I don't know how to simulate ECONNRESET.

From reading through the node groups, it seems that there are several
socket and HTTP agent related issues in node at the moment. I've
discovered some while working on a proxy of my own[1], but various
problems crop up even with a simple bare bones HTTP proxy like

https://gist.github.com/824818

If you get this running, and then point a web browser at
http://www.nytimes.com/ and click around a bit, with any luck you'll
get an exception within a few page loads. Some of this can and should
be handled by application code (one server was returning a response
without headers, for example) but I think some are due to problems in
node's own libraries, similar to the mismatch between the socket array
and the request queue, and how errors are migrated from one to the
other.

Michael

1. https://github.com/ithinkihaveacat/node-fishback

--
http://beebo.org
+44 78 2118 9049

Reply all
Reply to author
Forward
0 new messages