-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Buggy close()
routine - Node "hangs"
#150
Comments
I am experiencing the exact same problem. |
Any thoughts on this one @voodootikigod? |
If you need your app to quit – a workaround is to use |
@Starefossen - |
Hey all, Sorry been busy planning JSConf and having a baby. @bminer the bold "really" and calling things lame isn't cool. While I fully get the frustration, I can definitely use a bit more data about what is going on, can someone please provide an strace/dtrace output of the execution. This will drastically help expedite a fix. |
Hi @voodootikigod, Congrats on becoming a father! I wish I lived closer to the US so I could participate in JSConf! Here is my strace log: http://pastebin.com/PXhYKPTs Tested on NodeJS v0.10.5 on Ubuntu Server 12.04.2 32 bit |
awesome! thanks, will dig into. On Fri, Apr 26, 2013 at 12:11 PM, Hans Kristian Flaatten <
Chris Williams @voodootikigod http://twitter.com/voodootikigod | The things I make that you should check out: Help me end the negativity on the internet, share |
@voodootikigod - Congrats on the infant, and I understand that you're busy. I wasn't trying to offend anyone by pulling the lame card. Thanks @Starefossen for providing the strace. I'll try to dig into this, as well, time permitting. |
I've just tested this and I didn't have a problem. I'm using Ubuntu 12.04 64bit version and node.js v0.10.5. I should note that the example code posted by the op doesn't work on Linux by default. I had to change var SerialPort = require("SerialPort").SerialPort; to var SerialPort = require("serialport").SerialPort; @Starefossen is your system 32 or 64 bit? Otherwise I'm not sure what is different between our systems. :edit: Just realised that one difference is that I'm receiving data on the port. :edit 2: Yep, just retested with my device disconnected and I get the problem. So it only occurs if no data has been received (or maybe it's no data on the input buffer) when you close the serial port. If you are receiving data then it works fine. In my case I'm receiving telemetry from a UAV and it's very rapid. Hope that helps in finding the problem. Cheers, |
@jamesjenner I am actually running the 32 bit version of Ubuntu. I am receiving data from the device with no problems; and the device is connected during the entire session. However; the example program never terminates, it just hangs when attempting to cose the port. |
Hmm strange. In my case i can close the port and the program will terminate if I'm receiving data. The program only hangs if I attempt to close the port when the port has not received data. |
I can also confirm that whether I receive data or not, the port does not seem to close successfully, and Node will hang. Using Debian Wheezy (7.0) 64-bit. |
I'm seeing this issue on OS X as well. Sometimes it won't close the connection (when I forcefull kill node), which leaves me no choice but to physically disconnect the device. Since the device is an FTDI chip, this often kernel panics my Mac. I looked at the code and could not find the issue cleanly, other that the close(fd) doesn't while if it returns an error. (It can be interrupted.) |
I'm seeing the same issue on OSX 10.7.5. Like @amesjenner I am only able to close the port and have node exit properly once I've received some data from the serial port. |
Flow control options haven't been added to windows yet.
@giseburt, that fix doesn't work for me. I haven't really looked into the matter. I just want a fix/work-around. I publish solution here in case it might help anyone else. I use USB serial port. As mentioned here, communication can have a tendency to lock up (stops receiving data and can prevent process from exiting). Neither of those provided an desired solution. I found this: When node/serialport locks up the ports, this reset provides an effective work-around that restores communication. |
I'm facing same issue in beaglebone black (node 0.8.22, node-serialport 1.1.3). Node is not quitting after closing the port. |
Please try this with the latest 1.2.1 release. |
I tried with 1.2.1. I confirm that the hang on close is gone. I also performed a second open in the same process and it opened and closed as expected. I also aborted the port in mid test and sometimes I saw the error surface via the node-serialport error event, but sometimes I also hit a crash. I used socat on ubuntu 13.04 to test, creating the port pair via:
and testing by changing the port in the sample above to
|
I missed 1.2.1 but confirm 1.2.2 works for me. Process closes/kills without hanging. Subsequent runs receive and transmit data as expected. Super Awesome! Thanks much! |
Closing ticket. |
Thanks, guys! What a major improvement! |
=D 👍 |
The serial port does not properly close on Debian Linux. The "close" event is fired, however. In addition, Node will hang even after
close()
is called.Code to reproduce:
Output when you run this program:
Then... Node just hangs forever... (undesirably)
Furthermore, if I remove the serial port (i.e. /dev/ttySerial0 goes away), I get the following error:
Then Node crashes. How could there be an unhandled error event if I am binding an event listener to the "error" event, as shown in the code above?
This is a bit buggy. Maybe the
close()
routine doesn't really release the serial port... I've found that if I try to re-use the port, an error occurs. Thoughts?The text was updated successfully, but these errors were encountered: