question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Occasionally an error occurs when calling findByIds / usb.getDeviceList()

See original GitHub issue

Environment

  • win7 64bit
  • electron 12
  • usb 1.7.1

Error stack

image

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:closed
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gniezencommented, Mar 25, 2022

Amazing work, thanks @mildsunrise !

1reaction
mildsunrisecommented, Mar 24, 2022

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 to Device? in that case it should be easy to fix. I’ll debug more later.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found