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

Disconnecting serial cable crashes node #587

Closed
lizhouatforte opened this issue Sep 16, 2015 · 6 comments
Closed

Disconnecting serial cable crashes node #587

lizhouatforte opened this issue Sep 16, 2015 · 6 comments

Comments

@lizhouatforte
Copy link

lizhouatforte commented Sep 16, 2015

on node 0.10.36 with serial port 1.7.4 on windows 7 64bit

If I run node with serial cable plugged, then unplug the cable, the node is crashed.

Here is my code:

var serialport = require("serialport");
var sp = null;
serialport.list(function (err, ports) {
            ports.some(function (port) {
                sp = new serialport.SerialPort(port.comName, { baudrate: 19200 });
                sp.on('open', function () {
                    console.log('Opened ' + port.comName);
                });
                sp.on('error', function () {
                    console.log('Errored!!!');
                });
                sp.on('close', function () {
                    console.log('Closed!!!');
                });
                return true;
            });
        });

The console output is:

Opened COM3

undefined:0
TypeError: undefined is not a function

I appreciate any input why error/close events are not triggered. Thanks!

@reconbot
Copy link
Member

I figured out why, this is bananas. Adding this to the backlog as disconnect is not documented or working properly.

@reconbot
Copy link
Member

I figured out why, this is bananas. Adding this to the backlog as disconnect is not documented or working properly. #638

@reconbot
Copy link
Member

reconbot commented Apr 6, 2016

Disconnect still removes all events but it does it after emitting disconnect and error events. We're going to stop doing this behavior in the next major release.

We fixed a ton of bugs in our latest beta specifically ones addressing this issue. #733 Please try it out [email protected] and report back!

@reconbot
Copy link
Member

The CPU issue seems fixed but the port can't be reopened. Still an issue.

@reconbot
Copy link
Member

reconbot commented Sep 2, 2016

Per #919 window's serialport poller will emit errors on disconnect that can't be caught.

@reconbot
Copy link
Member

reconbot commented Jul 8, 2017

This is fixed with 5.0.0-beta6

@reconbot reconbot closed this as completed Jul 8, 2017
@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.
Development

No branches or pull requests

2 participants