Repository navigation
Conversation
On Linux machines with no USB bus (often containers), /sys/bus/usb/devices doesn't exist. nusb reports that as an error, so getDevices, findDeviceByIds and findDeviceBySerial all rejected. addEventListener's initial device list had no catch, which caused an unhandled rejection.
kevinmehall
reviewed
Oct 15, 2026
Comment on lines
165
to
+173
|
|
||
| // A Linux machine without a USB bus (often a container) has no | ||
| // /sys/bus/usb/devices. That means there are no devices, not that listing failed. | ||
| fn is_missing_usb_bus(e: &nusb::Error) -> bool { | ||
| cfg!(target_os = "linux") | ||
| && e.os_error().is_some_and(|code| { | ||
| std::io::Error::from_raw_os_error(code as i32).kind() == std::io::ErrorKind::NotFound | ||
| }) | ||
| } |
There was a problem hiding this comment.
I'd probably just do list_devices().wait().map_or(Vec::new(), |devices| devices.collect()) instead of testing for the specific error, since if you don't want it to fail in that case, you probably don't want it to fail in other cases either.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
On Linux machines with no USB bus (often containers), /sys/bus/usb/devices doesn't exist. nusb reports that as an error, so getDevices, findDeviceByIds and findDeviceBySerial all rejected. addEventListener's initial device list had no catch, which caused an unhandled rejection.
Fixes
I am not 100% sure on some of the TS error changes, but the
setTimeout(() => { throw error; }, 0)will always manifest as an uncaughtException unless the application sets up a handler for those errors, in which it is common to exit the application as a means to recover.Checklist
Have you...
See bitfocus/companion#4522 for the original error