Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kiakj opened this issue May 3, 2016 · 6 comments

Comments

@kiakj
Copy link

kiakj commented May 3, 2016

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)

@kanazir
Copy link

kanazir commented Dec 29, 2016

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

@pascalopitz
Copy link
Owner

pascalopitz commented Dec 29, 2016 via email

@marcoeg
Copy link

marcoeg commented Feb 4, 2017

@kanazir What alternative approach would you suggest?

@kanazir
Copy link

kanazir commented Feb 4, 2017

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...

@marcoeg
Copy link

marcoeg commented Feb 8, 2017

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

@marcoeg
Copy link

marcoeg commented Feb 15, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants