fix: stabilize device cleanup and pace Pro2/Neo USB signing - #919
Open
wabicai wants to merge 8 commits into
Open
fix: stabilize device cleanup and pace Pro2/Neo USB signing#919wabicai wants to merge 8 commits into
wabicai wants to merge 8 commits into
Conversation
originalix
reviewed
Sep 5, 2026
originalix
reviewed
Sep 5, 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.
Cancelling a BLE operation or immediately starting another call could overlap old connection setup or teardown. Repeated calls and SDK resets also left request records and React Native BLE resources behind.
Requests are registered before queue waits, and cancellation uses the existing request signal and per-device cleanup barrier. Device cancellation captures the old commands and run state and is deduplicated per connection attempt. Completed V1/V2 calls preserve their acknowledged result while registering the actual run cleanup with that same barrier, so the next acquire waits for release. A cleanup deadline does not make an unfinished connection reusable.
Pro2 and Neo signing calls over browser WebUSB, desktop WebUSB, and Node USB now append a one-second cooldown to that per-connectId post-call barrier. The current signing result is returned at the existing time; only the next device call waits. BLE, older device families, non-signing methods, and other devices remain unaffected. The same cooldown is registered after success, cancellation, or a signing error so an immediate retry cannot race device recovery.
React Native V1 cancellation rejects its pending read and waits for native disconnect. SDK disposal now reaches Core and drains the transport's scans, scan timers, pending reads and owned native connections. Ordinary disposal leaves the shared ble-plx manager available to other connectors. A manager reset waits for asynchronous singleton destruction before another transport can acquire; destruction failures or deadlines do not permit reuse of the old manager. Both SDK entries remove request records when calls settle, including out-of-order failures.
Connection setup failures stop the outer poll. Existing scan/connect/GATT timing logs remain available; scan windows, connection retry parameters and transfer packet sizes are unchanged.
Validation:
yarn agent:check --profile commitpassed on the latest commit.yarn workspace @onekeyfe/hd-core test device-lifecycle-events.test.ts --runInBandpassed: 83 tests.yarn workspace @onekeyfe/hd-core buildpassed.yarn agent:check --profile prreached full lint, then the local shared dependency environment failed while loading the TypeScript import resolver for the unrelatedexpo-playgroundfileCollapsibleJsonViewer.tsx; GitHub CI is running the clean-environment checks.yarn jest --runInBand --runTestsByPath packages/hd-ble-sdk/__tests__/device-state-events.test.ts packages/hd-common-connect-sdk/__tests__/device-state-events.test.ts.Companion App fix: OneKeyHQ/app-monorepo#13196.
Related symptom: https://onekeyhq.atlassian.net/browse/OK-62115.
Physical iOS/Android/Electron cancellation, transfer performance, Pro2/Neo continuous USB signing, and post-upload stability still require device validation. This does not establish the cause of the reported iOS freeze. SDK publication and the App dependency update are separate follow-up work.