File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ Subproject commit 544b33a507a3a3c368df7b8057b7c63d3ff6caa0
Original file line number Diff line number Diff line change 11// SPDX-License-Identifier: MIT
2- // Copyright (c) 2025 The Pybricks Authors
2+ // Copyright (c) 2025-2026 The Pybricks Authors
33
44import { firmwareVersion } from '@pybricks/firmware' ;
55import { AnyAction } from 'redux' ;
@@ -77,6 +77,11 @@ function* handleUsbConnectPybricks(hotPlugDevice?: USBDevice): Generator {
7777 // so that reducers still work correctly.
7878 if ( hotPlugDevice !== undefined ) {
7979 yield * put ( usbHotPlugConnectPybricks ( ) ) ;
80+
81+ // Even though we get the connect event, the browser does not
82+ // appear to be ready to open the device right away, so we add a
83+ // small delay before trying to connect.
84+ yield * delay ( 100 ) ;
8085 }
8186
8287 if ( navigator . usb === undefined ) {
@@ -655,6 +660,8 @@ function* handleUsbConnectEvent(): Generator {
655660 // if there is exactly one Pybricks device connected, we can connect to
656661 // it, otherwise we should let the user choose which one to connect to
657662 if ( pybricksDevices . length === 1 ) {
663+ // REVISIT: Device is passed as hotplug device, even though it is
664+ // not technically a hotplug event.
658665 yield * spawn ( handleUsbConnectPybricks , pybricksDevices [ 0 ] ) ;
659666 }
660667 }
You can’t perform that action at this time.
0 commit comments