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

Serialport on NW.js spontaneously closes app on some Windows machines when accessing 'undefined' port properties #894

Closed
nanowizard opened this issue Aug 5, 2016 · 4 comments
Labels

Comments

@nanowizard
Copy link

SerialPort version: 3.1.2
Operating System and Hardware: Dell Latitude E5520, Win 7 Pro, Core i5-2520M 2.5GHZ, 4GB RAM.
Are you using Electron/Atom/NwJS?: NW.js version 0.15.0

Problem

After making some changes to our app code, everything would work perfectly fine on most of our PCs, but on the Dell Latitude referenced above the app would close almost immediately after opening. After investigating with the dev tools on that machine I discovered it was occurring when processing the result of the SerialPort.list function. Specifically, it occurrs on the following line, where I create a label based on the port comName and manufacturer if it exists.

p.label = p.comName + (p.manufacturer ? ' ('+p.manufacturer+')' : '');

It appears to occur whenever I attempt to do any kind of boolean operation on a port property that shows up with the mysterious hole type. The following is a screenshot from some tests I was doing in the developer console, where I stored a port object as a global variable temp1:
wtf
After executing the command !temp1.manufacturer, the program immediately exited.

No errors are ever printed to the console. And the process closes with an exit code of 0.

Steps and Code to Reproduce the Issue

I am unsure specifically what kind of system configuration causes this to occur. As I mentioned above, everything worked fine on almost all of our other Windows machines. It could have been due to the fact that the manufacturer property on that port object was a hole type. I saw the same behavior when trying to do operations on the other properties set to hole.

On such a machine, the following code should reproduce the issue:

SerialPort.list(function(err, ports){
    ports.forEach(function(p){
        console.log(!p.manufacturer);
    });
});
@reconbot
Copy link
Member

reconbot commented Aug 5, 2016

I have never in my life seen a hole data type. I know it's a concept with arrays but...

I'd open an issue on nwjs. We provide a guaranteed undefined when information isn't available.

@reconbot
Copy link
Member

reconbot commented Aug 5, 2016

And totally report back here! Making it easy for people to use SP with whatever ideas they have is important to us. I'm happy to help debug on a nwjs ticket too.

@nanowizard
Copy link
Author

nanowizard commented Aug 9, 2016

Yeah I was completely baffled when I saw that hole type. As you recommended, I just opened the issue on nwjs. My workaround for the time being is to avoid doing any kind of boolean operations on those properties. So I changed this line:

p.label = p.comName + (p.manufacturer ? ' ('+p.manufacturer+')' : '');

To this:

p.label = p.comName + ' ' + p.manufacturer;

Which doesn't cause any problems.

@reconbot
Copy link
Member

reconbot commented Sep 6, 2016

Browser serialport as suggested in that ticket will soon be merged with node-serialport with a chrome serialport backend. It's not as up to date with the api, but it does work well. I'm going to close this ticket as it's an issue with NW.js

@reconbot reconbot closed this as completed Sep 6, 2016
@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
Development

No branches or pull requests

2 participants