Repository navigation
firmware: give the update handshake a deadline - #402
Open
zunda-pixel wants to merge 2 commits into
Open
zunda-pixel wants to merge 2 commits into
zunda-pixel wants to merge 2 commits into
Conversation
Everything else that waits for one of the watch's answers has one. The negotiator bounds the version request at 20s and reports a null WatchInfo; requestFirmwareUpdateStatus bounds itself at 15s and returns null so the transfer starts from scratch. The start handshake was the exception: if the watch never answered FirmwareUpdateStart, beginFirmwareUpdate sat on the await, leaving _firmwareUpdateState on whatever it held and the interrupted update unrecorded, until the connection scope was cancelled from somewhere else. Bounded the same way, and an unanswered start now takes the path a refused one already took. Deliberately withTimeoutOrNull rather than withTimeout: the catch below this takes CancellationException to mean the download failed and rethrows, so a TimeoutCancellationException would be reported as ErrorDownloading, which is neither what happened nor recoverable in the same way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 3, 2026
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.
beginFirmwareUpdatewaits for the watch to answerFirmwareUpdateStartwith no deadline. If the answer never comes, it sits on theawait:_firmwareUpdateStatekeeps whatever value it held, nothing is reported as failed, andinterruptedUpdatesis never told about the attempt. It only unblocks when the connection scope is cancelled from somewhere else.Everything else in this path already has a deadline:
requestWatchVersion→requestWatchColorNegotiator.negotiate, which catchesTimeoutCancellationExceptionand returns a nullWatchInforequestFirmwareUpdateStatuswithTimeoutOrNull, returning null so the transfer starts from scratchsendFirmwareUpdateStartSo this gives it the same 15 seconds, and an unanswered start now takes the path a refused one already took —
error(...), caught by theIllegalStateExceptionbranch below,Idle(e).Why
withTimeoutOrNulland notwithTimeoutThe
trythis sits in hasTimeoutCancellationExceptionis aCancellationException, sowithTimeouthere would be reported as a download failure — neither what happened nor recoverable the same way. There is a comment on the call saying so, since the next person to touch it will reach forwithTimeoutfirst.