A forked process end
s connections when these 2 conditions exist in the child
:
- The child process thread takes longer than ~2 seconds to start.
- The child makes a
http
request.
NOTES:
- This is only happens to the sockets that are given to the
child
before thechild
is done loading. - I'm running
node v0.10.18
and have not tried on any other versions (yet). - NODE_DEBUG="net http" didn't reveal anything helpful.
- This is on OSX 10.7.5
Run in terminal #1:
node nag.js
Run in terminal #2:
node app.js
Once you start to see the ISO dates printing, the demo is over and you can terminate everything.
The purpose of nag
is to simulate the reconnect behavior of an EventSource. By eliminating the browser, I ruled out this being some kind of problem with Chrome's EventSource implementation.
The output
$ node nag
connecting...ECONNREFUSED.client closed
connecting...ECONNREFUSED.client closed
connecting...ECONNREFUSED.client closed
connecting...connected.client closed
connecting...connected.client closed
connecting...connected.client closed
connecting...connected.client closed
connecting...connected.
Yo! Want to play with matches?
client closed
connecting...connected.
HEY! Why did you run off like that!?!?!?
data:2013-09-07T16:02:18.144Z
data:2013-09-07T16:02:19.226Z
data:2013-09-07T16:02:20.304Z
To create this isolated issue, I started with the Example: sending socket object from the 'child_process` docs which hands sockets off a child processes to handle.
It simulates my situation where requests are only handled if a child process exists. A child process is created when a scheduled task creates it. Once created and doing it's job- it streams events to any sockets that are listening.
The output
$ node app
new request
T minus 3
new request
T minus 2
new request
T minus 1
new request
gotime!
The child is born
new request
modules loaded
parent says 'talk to your riend'
have fun kids
He doesn't want to play anymore :(
Google responded: 200
new request
parent says 'talk to your friend'
The cat came back
have fun kids
Google responded: 200
Google responded: 200