nodestalker icon indicating copy to clipboard operation
nodestalker copied to clipboard

looks like there is a problem getting a connection after about 20000-30000 requests are processed.

Open kiakj opened this issue 9 years ago • 6 comments

I'm running a batch process and it hits this error consistently after 20000-30000 jobs.

version 0.1.21

events.js:141 throw er; // Unhandled 'error' event ^

Error: connect EADDRNOTAVAIL localhost:11300 - Local (localhost:0) at Object.exports._errnoException (util.js:856:11) at exports._exceptionWithHostPort (util.js:879:20) at connect (net.js:843:14) at net.js:938:9 at nextTickCallbackWith0Args (node.js:452:9) at process._tickCallback (node.js:381:13)

kiakj avatar May 03 '16 21:05 kiakj

Looks like stack overflow to me. If you use their approach from README, it will cause it, for sure.

kanazir avatar Dec 29 '16 02:12 kanazir

If possible, try and take core dumps periodically, then use chrome debugger to compare them. This will reveal what's not getting garbage collected. Heapdump is a package that I'm using in my day job to do that.

On 29 Dec 2016 1:00 PM, "Vladimir Kanazir" [email protected] wrote:

Looks like stack overflow to me. If you use their approach from README, it will cause it, for sure.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pascalopitz/nodestalker/issues/25#issuecomment-269573016, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQlfARvKPzN_5T1z--11JB48fOO-guwks5rMxs2gaJpZM4IWpln .

pascalopitz avatar Dec 29 '16 04:12 pascalopitz

@kanazir What alternative approach would you suggest?

marcoeg avatar Feb 04 '17 16:02 marcoeg

Well, I am not the expert in node (I used it in only once in small IoT project) but you should not call the function recursively because it will cause stack overflow, eventually (javascript has no tail recursion). The better approach is to emit an event (and call callback function) every time the data is received.

For example, serialport does it that way.

I hope this helps...

kanazir avatar Feb 04 '17 23:02 kanazir

If that is your concern node version 6.2 supports tail call optimization: http://node.green/#proper-tail-calls--tail-call-optimisation-

marcoeg avatar Feb 08 '17 17:02 marcoeg

Using setTimeout(resJob, 0) in the example provided, even if recursive, it would clear the call stack. I have tested it and it is a simpler alternative to using events.

marcoeg avatar Feb 15 '17 19:02 marcoeg