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

Uncaught exceptions can cause node to hang #282

Closed
bminer opened this issue Dec 19, 2013 · 8 comments
Closed

Uncaught exceptions can cause node to hang #282

bminer opened this issue Dec 19, 2013 · 8 comments

Comments

@bminer
Copy link

bminer commented Dec 19, 2013

In certain situations, process.exit(1) or an uncaught exception will cause the Node.js process to hang when using node-serialport. The desired behavior is for the Node process to die. Instead, the process remains open and just hangs.

I am working on some reproducible code to demonstrate this bug. I am fairly certain that node-serialport is the culprit... it reminds me of issue #150.

This problem occurs on node-serialport 1.2.5. Node 0.10.22. Debian Linux 7.0

@bminer
Copy link
Author

bminer commented Dec 24, 2013

Update: I have narrowed the problem to an issue with the getaddrinfo system call (see related issue nodejs/node-v0.x-archive#2868). When dns.lookup fails due to a network connectivity problem, there are long delays reading the serial port. Eventually, the getaddrinfo system call returns the ENOTFOUND error, and then Node hangs.

Why node-serialport causes this hang-up... I still don't know. But, it's probably related to getaddrinfo sharing the thread pool with node-serialport.

Very interesting and strange...

@ruswerner
Copy link

I also have this problem. I'm running on Rasbian kernel 3.10.24+, node v0.10.12. I like to resume stdin and then listen for the 'SIGINT' event on process. Then I cleanup open ports and other application stuff,and explicitly call process.exit(). If I call serialPort.close() in my SIGINT handler, then try to call process.exit(), it just hangs. I have to ctrl-Z and kill -9 node to recover.

This is really annoying, because I would like to call process.exit() in the serial.close() callback function to ensure everything is closed properly, but it just hangs.

So at this point, I just don't close the serial port. It seems to be fine; I'm just using the /dev/ttyAMA0 (rx/tx pins) on the rpi to talk to an arduino.

Anyone have any more info on this?

@JayBeavers
Copy link
Collaborator

What a fascinating bug, great sleuthing @bminer! Do you have a recommended fix and if so could you submit a pull request?

@bminer
Copy link
Author

bminer commented Jan 18, 2014

@JayBeavers - Unfortunately, I do not have a fix at this time. It's also pretty tough to reproduce the problem. (sigh)

If I find any more information, I will post back here.

@bminer bminer closed this as completed Jan 18, 2014
@bminer bminer reopened this Jan 18, 2014
@voodootikigod
Copy link
Collaborator

@bminer any update or data?

@bminer
Copy link
Author

bminer commented Jan 6, 2015

Sadly, no. I do not have time ATM to debug this issue. However, I can say that libuv is working on separating the thread pools for different tasks (libuv/leps#4). And, they are working on an approach to allow reading from TTY/serial ports (libuv/libuv#19). So, eventually, these wonderful things will make it to Node.js.

In the meantime, I have been using node-serialport and other libs to address the issue, and I just deal with the bugs.

@reconbot
Copy link
Member

We've had a lot of similar bugs fixed as well as some major rewrites of our c++ code since this bug was filed. I sure hope we caught this bug, but since it was never quite identified, I'm closing this issue.

@bminer
Copy link
Author

bminer commented Mar 28, 2016

Sounds good, thanks. I'm not sure if it's still an issue or not either. I've been pretty happy with the stability improvements made to this lib.

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants