Occasionally an error occurs when calling findByIds / usb.getDeviceList()
See original GitHub issueEnvironment
- win7 64bit
- electron 12
- usb 1.7.1
Error stack
What went wrong
exports.findByIds = function(vid, pid) {
var devices = usb.getDeviceList() // ** That's what went wrong here
for (var i = 0; i < devices.length; i++) {
var deviceDesc = devices[i].deviceDescriptor
if ((deviceDesc.idVendor == vid) && (deviceDesc.idProduct == pid)) {
return devices[i]
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Developers - Occasionally an error occurs when calling findByIds ...
Occasionally an error occurs when calling findByIds / usb.getDeviceList()
Read more >hacker noon - Freshnews.org
Automated auditing is the process of checking code for errors using auditing tools. ... The issue here is obvious. ... getDeviceList() let device...
Read more >node-usb from node-usb - GithubHelp
getDeviceList(). Return a list of legacy Device objects for the USB devices attached to the system. findByIds(vid, pid). Convenience method to get the ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Amazing work, thanks @mildsunrise !
Okay, it took me a while to realize this “Invalid argument” error message does not come from libusb, it seems to be an N-API error: https://github.com/nodejs/node/blob/718be08686312d19645861b9715491a49ee3c9cb/src/js_native_api_v8.cc#L730 which is thrown as a C++ exception by the N-API C++ wrapper.
maybe
napi_invalid_arg
is thrown here, when attempting the conversion toDevice
? in that case it should be easy to fix. I’ll debug more later.