Repository navigation
refactor(core): centralize result retries #9220
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
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
615725f
refactor(core): centralize result retries
cv 29e1993
refactor(core): reuse bounded retry helpers
cv 4a5205f
docs(core): clarify retry helper wording
cv 036043a
fix(core): normalize retry delay units
cv cde1f94
fix(core): preserve GPU patch sleep units
cv 3e28ca9
test(core): name GPU sleeper binding regression
cv 9574daa
test(core): cover async immediate retry acceptance
cv 9c94660
fix(core): preserve zero retry attempt budgets
cv a0c9e3e
test(core): clarify sleeper behavior titles
cv 8409644
refactor(inference): reuse bounded retry helpers
cv 3eae0cf
refactor(dns): reuse bounded retry helper
cv e2ae02a
refactor(core): extract remaining bounded retries
cv 1624fc4
refactor(core): simplify retry adoption
cv d93d907
test(core): keep retry cases linear
cv a8e2682
test(core): preserve connect retry coverage
cv 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| interface RetryUntilBaseOptions<T> { | ||
| /** Return true to stop retrying after this result. */ | ||
| accept: (result: T, attempt: number) => boolean; | ||
| /** Delay in milliseconds before each additional attempt. */ | ||
| retryDelaysMs: readonly number[]; | ||
| } | ||
|
|
||
| export type RetryUntilOptions<T> = RetryUntilBaseOptions<T> & { | ||
| /** Sleep for the specified number of milliseconds between attempts. */ | ||
| sleep: (ms: number) => void; | ||
| }; | ||
|
|
||
| export type RetryUntilAsyncOptions<T> = RetryUntilBaseOptions<T> & { | ||
| /** Sleep for the specified number of milliseconds between attempts. */ | ||
| sleep: (ms: number) => Promise<void>; | ||
| }; | ||
|
|
||
| /** | ||
| * Retry a synchronous operation until its result is accepted or the delay | ||
| * schedule is exhausted. Returns the final operation result. | ||
| */ | ||
| export function retryUntil<T>(operation: (attempt: number) => T, options: RetryUntilOptions<T>): T { | ||
| let attempt = 1; | ||
| let result = operation(attempt); | ||
| if (options.accept(result, attempt)) return result; | ||
|
|
||
| for (const delayMs of options.retryDelaysMs) { | ||
| options.sleep(delayMs); | ||
| attempt += 1; | ||
| result = operation(attempt); | ||
| if (options.accept(result, attempt)) return result; | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Retry an asynchronous operation until its result is accepted or the delay | ||
| * schedule is exhausted. Returns the final operation result. | ||
| */ | ||
| export async function retryUntilAsync<T>( | ||
| operation: (attempt: number) => T | Promise<T>, | ||
| options: RetryUntilAsyncOptions<T>, | ||
| ): Promise<T> { | ||
| let attempt = 1; | ||
| let result = await operation(attempt); | ||
| if (options.accept(result, attempt)) return result; | ||
|
|
||
| for (const delayMs of options.retryDelaysMs) { | ||
| await options.sleep(delayMs); | ||
| attempt += 1; | ||
| result = await operation(attempt); | ||
| if (options.accept(result, attempt)) return result; | ||
| } | ||
| return result; | ||
| } |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.