fix: correct deadline logic in _wait_for_finish#749
Open
Conversation
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (33.33%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #749 +/- ##
==========================================
- Coverage 95.22% 95.13% -0.09%
==========================================
Files 45 45
Lines 5154 5164 +10
==========================================
+ Hits 4908 4913 +5
- Misses 246 251 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Make the not-found deadline lazy (starts on the first observed 404 and resets after any successful response) and honor the user-provided wait_duration in the 404 branch. This prevents a single transient 404 from aborting a long poll early, and prevents overruns when the user's deadline is shorter than DEFAULT_WAIT_WHEN_JOB_NOT_EXIST. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b9a24dc to
122f101
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.
Summary
Fixes two bugs in
ResourceClient._wait_for_finish/ResourceClientAsync._wait_for_finish:not_found_deadlineanchored at function entry. The 3-second "job not found" grace window was computed once at entry and never reset. A single transient 404 (e.g. replica lag) during a long poll could terminate the wait and returnNoneeven though the job was live. The deadline is now lazy — it starts on the first observed 404 and resets after any successful response, so each run of 404s gets its own fresh window.User
wait_durationnot checked on 404. Whenwait_durationwas shorter thanDEFAULT_WAIT_WHEN_JOB_NOT_EXIST(3s) and the API returned persistent 404s, the loop could overrun the documented contract by up to ~3s. The 404 branch now checks the user deadline first.Applied symmetrically to the sync and async mirrors.