Just found a serious bug in the http client. When I make a request to
an unreachable server or to a firewalled port and set a timeout on the
client, node won't close the connection when the timeout is reached,
and it will be sending 'timeout' events indefinitely while keeping the
socket open in SYN_SENT state. Also tried to do "client.forceClose()"
after receiving a 'timeout' event, but node just segfaults.
Here's a simple test case: http://gist.github.com/311783
And here's a sample output (202.129.49.242 is an unreachable IP):
$ node test.js http://202.129.49.242:8030/
DEBUG: [1002] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
DEBUG: [60004] Timeout: undefined
Closing...
Segmentation fault
$
Here's what I get from GDB:
1) http://gist.github.com/311784 (dies in node_net.cc:262
assert(connection->host_ == NULL);)
After commenting that line, I get:
2) http://gist.github.com/311791 (dies in node_net.cc:296
assert(connection->refs_);)
After commenting that line, I get:
3) http://gist.github.com/311793 (dies in node_net.cc:325
assert(connection->refs_);)
After commenting that line, I get:
4) http://gist.github.com/311796 (dies in node_net.cc:201
assert(stream_.recvfd < 0 && "garbage collecting open Connection");)
After commenting that line, I get:
5) http://gist.github.com/311799 (dies in node_net.cc:202
assert(stream_.sendfd < 0 && "garbage collecting open Connection");)
After commenting that line, I finally get the segfault:
6) http://gist.github.com/311802 (segfaults)
Sorry if I'm being too verbose, I just want to help as much as
possible. Let me know if you need anything else.
Cheers,
Peter
Yeah - that seems to be a problem. Try the attached very hacky fix.
I'd like to have a nice test/mjsunit test for this but I haven't been
able to do figure out something self-contained.
It'd be nice, though, to have an error description like 'timeout' when
the 'error' event is sent after the timeout.
I could try to write a a mjsunit test for this. Isn't the script I
posted above self-contained?
On Feb 23, 3:25 am, Ryan Dahl <coldredle...@gmail.com> wrote:
> 0001-Add-hack-to-get-error-event-on-socket-timeout.patch
> 1KViewDownload
Self-contained would be one that doesn't rely on a certain internet
address being in a certain state.