Skip to content

Commit 872ba15

Browse files
committed
fix: changing usbDevice.configuration condition check to evaluate undefined and null as well
1 parent de2a9cb commit 872ba15

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/usb/sagas.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
164164
// REVISIT: For now, we are making the assumption that there is only one
165165
// configuration and it is already selected and that it contains a Pybricks
166166
// interface.
167-
if (usbDevice.configuration === null && usbDevice.configurations.length > 0) {
167+
168+
if (
169+
(usbDevice.configuration === undefined || usbDevice.configuration === null) &&
170+
usbDevice.configurations.length > 0
171+
) {
168172
const [, selectErr] = yield* call(() =>
169173
maybe(
170174
usbDevice.selectConfiguration(
@@ -181,7 +185,7 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
181185
}
182186

183187
assert(
184-
usbDevice.configuration !== undefined,
188+
usbDevice.configuration !== undefined && usbDevice.configuration !== null,
185189
'USB device configuration is undefined',
186190
);
187191
assert(

0 commit comments

Comments
 (0)