fix: bound BLE acquire with a deadline and wire cancel into in-flight connects - #889
Closed
originalix wants to merge 4 commits into
Closed
fix: bound BLE acquire with a deadline and wire cancel into in-flight connects#889originalix wants to merge 4 commits into
originalix wants to merge 4 commits into
Conversation
Contributor
Author
Contributor
Author
|
Added two follow-up commits after an adversarial self-review: (1) attach the acquire promise handlers before the aborted-at-entry early return and skip starting an acquire when the signal is already aborted — otherwise a cancel landing during the 3s retry backoff starts a post-cancel acquire whose eventual rejection is unhandled; (2) release the request-queue task on the |
Contributor
Author
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.
Context
Field incident (6.5.0 desktop, Classic 1S onboarding):
checkAllFirmwareReleasehung for 306 s insideensureConnected → connectDeviceForBle → device.acquire(). The Electron main process lost the$onekey-noble-ble-connectIPC reply in a two-connect race, and nothing on the renderer/hd-core side could unstick the call:ensureConnectedclears its per-tryPollingTimeouttimer before awaitingconnectDeviceForBle, so the await has no deadline;cancel()had no effect until Electron GC finally reported "reply was never sent" ~5 minutes later.The main-process no-reply hole is fixed since the keep-alive series (#847 wraps every noble callback in
runBleCallbackOperationwith timeouts), but hd-core still trusts any transport to always settle. This PR closes the structural hole.Changes
raceBleAcquire: racesdevice.acquire()against a 60 s deadline (BleTimeoutError, which the existing retry loop already handles) and the caller'sAbortSignal(CallQueueActionCancelled, immediate).deviceConnector.disconnect+markTransportDisconnected) before rethrowing, so the retry cold-connects instead of stacking a second connect onto the half-open one — same recovery pattern the file already uses forERROR_CODES_REQUIRE_DISCONNECT.abortSignalis threaded fromensureConnectedintoconnectDeviceForBle(and its retries), andCallQueueActionCancelledis added toensureConnected's immediate-reject list so a cancel fails the call now instead of after another poll round.Verification
tsc --noEmiterror set identical to base (pre-existing unresolved-workspace-import errors only);eslintclean of new findings.