Replace thread.sleep in sync exchange v2 with coroutine-based delay#8986
Open
CDRussell wants to merge 1 commit into
Open
Replace thread.sleep in sync exchange v2 with coroutine-based delay#8986CDRussell wants to merge 1 commit into
CDRussell wants to merge 1 commit into
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
a7181fd to
63e932f
Compare
63e932f to
15b9f51
Compare
15b9f51 to
00e6b25
Compare
20 tasks
f7f50f7 to
cbdc0d4
Compare
9adc18b to
b0288d5
Compare
cbdc0d4 to
6089722
Compare
b0288d5 to
8343770
Compare
6089722 to
0cd4c09
Compare
0cd4c09 to
68ef3a9
Compare
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.

Task/Issue URL: https://app.asana.com/1/137249556945/project/72649045549333/task/1215729137633076?focus=true
Description
Replaces two
Thread.sleep(...)calls in the sync v2 retry-backoff loops withdelay(...):ThirdPartyCredentialManager.retryingOnRateLimit(used when extending the account with a 3party credential and the server rate-limits the call)SyncAccountRepository.retryingOnTransientError(used during the 3party → ddg upgrade login)Switching to
delayrequired asuspendcascades a little to these:ThirdPartyCredentialManager.create()SyncAccountRepository.createThirdPartyCredential()andjoinAccountFromThirdPartyRecoveryCode()RecoveryCodeProvider.createThirdPartyCredentialIfNeeded()ExchangeV2Runner.shareRecoveryCodeAndAdvanceLockedso the recovery-code fetch+send runs inside the launched coroutine instead of synchronously before it.Intentional behaviour changes
shareRecoveryCodeAndAdvanceLocked, the network work now runs inside the launched coroutine and outsidemutex.withLock, so retry backoff doesn't block the dispatcher thread. A short-circuit at the top of the launch handles the common cancel-before-run race; any work that proceeds past it is best-effort, and any orphaned server-side credential is cleaned up by the BE's 5-min TTL.Steps to test this PR
UI changes
None.
Note
Medium Risk
Touches 3party credential minting and account-join upgrade flows plus v2 pairing host recovery-code timing; the runner mutex change can alter concurrency during pairing but is intentional to avoid blocking the SM.
Overview
Replaces
Thread.sleepwithdelayin sync v2 retry backoff loops (ThirdPartyCredentialManagerrate-limit and concurrent-modification retries,SyncAccountRepository.retryingOnTransientErrorduring 3party→ddg upgrade). That drives asuspendcascade through 3party credential creation,joinAccountFromThirdPartyRecoveryCode,RecoveryCodeProvider.createThirdPartyCredentialIfNeeded, and the dispatcher’s v2 outcome mappers that call those APIs.In
ExchangeV2Runner.shareRecoveryCodeAndAdvanceLocked, host recovery-code provisioning and send now run inside the launched IO coroutine (with an earlysession == nullexit) instead of synchronously beforelaunch, so retry backoff and account/credential network work no longer run while the exchange state-machine mutex is held.Affected unit tests are updated to use
runTestfor the new suspend entry points.Reviewed by Cursor Bugbot for commit 68ef3a9. Configure here.