A followup in case other people want to avoid this same issue: I patched our node fork [1] to deal with this (and possibly some other related issues that would cause the same effect - it seems there are a few process.nextTicks going on that make things not particularly robust). I also set up a test case to reproduce this issue [2], though it reproduces the symptom more than the cause, but since my, admittedly fairly hacky, fix mostly just detects and fixes the symptom, it was enough to ensure my fix worked.
[1] https://github.com/Jimbly/node/commit/ea583f651414449db4d8a82b9fbc92b039be8409 [2] https://gist.github.com/3669555 Jimb Esser Cloud Party, Inc On Tuesday, September 4, 2012 11:35:31 AM UTC-7, Jimb Esser wrote: > > It seems leaving the process.nextTick is fine, as long as it emits an > error/close after the callbacks are registered if the error event was in > fact missed between ticks, which seems like something easy to check for and > a good interim fix if there is some larger architectural fix planned later. > I'll probably be patching this up in our node fork and can send a pull > request if desired. > > Thanks for the information. > > On Tuesday, September 4, 2012 11:28:48 AM UTC-7, Ben Noordhuis wrote: >> >> On Tue, Sep 4, 2012 at 7:49 PM, Jimb Esser <[email protected]> wrote: >> > In http.js in the node source, ClientRequest.prototype.onSocket uses >> > process.nextTick before setting up the error and close handlers, but it >> > seems that a socket can be closed before that callback and the error >> > handlers will never be called. Is this a bug? Is there something I'm >> > missing that would make this code somehow safe? >> > >> > Why I ask is that under high load, we've had some HTTP requests end up >> never >> > completing, never getting an error, and the OS reports having no open >> > sockets. I added an on('socket') event that asserted that the socket >> we're >> > handed was not already disconnected, and this has started firing, which >> > means we're being handed a disconnected socket (and any error or >> disconnect >> > events we set immediately upon creating the request will never get >> called. >> > This is in the context of a large application with a lot of other stuff >> > going on, so it's possible we have a bug elsewhere, but tracing up the >> > callstack when we get passed a disconnected socket makes me think this >> code >> > in http.js that may be at fault. >> >> It's a know bug, there are several bug reports about it. It'll be >> addressed eventually but the problem is that the nextTick is there for >> a reason, removing it introduces other issues. >> > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
