-
Notifications
You must be signed in to change notification settings - Fork 29
Bound the BLE connect and file-read waits so they report instead of hanging #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
makermelissa
merged 10 commits into
circuitpython:main
from
dhalbert:bound-ble-connect-timeouts
Aug 21, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cb1a134
Bound the BLE connect so it can't hang forever
dhalbert c84e3a7
Report a failed BLE file read instead of hanging on it
dhalbert f6ac81b
Shorten the advertisement wait and say something during it
dhalbert 0c197d4
Bound the silent reconnect's connect too
dhalbert f7edefe
Abort the advertisement watch before connecting, not after
dhalbert 3113ab6
Correct the ble.js comments to match what the investigation established
dhalbert 2bd1935
Don't name a device in the status while racing several
dhalbert 8c66922
Merge remote-tracking branch 'circuitpython/main' into bound-ble-conn…
dhalbert e6d68ce
Take ble-file-transfer-js 1.1.0 and drop the local read guard
dhalbert 4a89ca5
Force a CCCD write when subscribing to BLE serial
dhalbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use the timeout function in https://github.com/circuitpython/web-editor/blob/main/js/common/utilities.js#L2 here, which basically already does this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude wrote this:
Switched to
timeout():device.gatt.disconnect()has to stay.timeout()abandons the promise, and an abandonedgatt.connect()keeps running in the browser process;disconnect()is the only way page JS can cancel it, and Chrome has honoured it as a cancel since M140. Calling it on any rejection rather than only on the timeout is what keeps this to atry/catch—disconnect()on a device that is not connected is a no-op.Also needs
timeoutadded to theutilities.jsimport. One small loss: a timeout now logsTimed Outrather thanconnect did not complete within 30s, which was console-only.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the above look to you? I can submit a commit for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update timeout to work better? One of the reasons it's nice to have in one place is updating it improves it everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude wrote this:
Yes. Two things, for every caller: clear the timer when the callback wins, and pass the callback an
AbortSignalthat fires on timeout so it can stop what it started —Promise.race()abandons the loser, it doesn't cancel it. Today that leaves the BLE connect running in the browser process, and the connect wait inweb.jspolling every 100 ms for the life of the page.Existing callers ignore the extra argument. The BLE side becomes:
Want the
web.jsloop fixed here too (&& !signal.aborted), or separately?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do it in a separate pr.