fix: use TotalSeconds/TotalMilliseconds in WaitAndRetry timeout comparison#134
Merged
mattburton merged 1 commit intoMay 27, 2026
Merged
Conversation
3df3fa1 to
2ad7077
Compare
…rison TimeSpan.Seconds returns only the seconds component (0-59), not the total seconds. For timeouts >= 60 seconds (e.g. the default 60s), .Seconds is 0 because it's exactly 1 minute. This caused WaitAndRetry to always throw a timeout exception instead of retrying, with the misleading message 'The request took longer than the 0 milliseconds allowed'. The fix uses .TotalSeconds and .TotalMilliseconds which return the full value regardless of magnitude. Added regression tests for timeouts >= 60s and correct millisecond reporting in error messages. Bumps version to 3.2.1.
2ad7077 to
396e1a1
Compare
joshuaflanagan
approved these changes
May 27, 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.
Problem
WaitAndRetryusesconfig.Timeout.Secondsandconfig.Timeout.Millisecondsto decide whether a retry-after delay exceeds the configured timeout. These properties return only the component of the TimeSpan (0-59 for seconds, 0-999 for milliseconds), not the total value.For the default timeout of 60 seconds (
TimeSpan.FromSeconds(60)):.Seconds→ 0 (because it's exactly 1 minute).Milliseconds→ 0This means any 429 response with a
RetryAfterheader > 0 will immediately throw aShipEngineExceptionwith the misleading message:...instead of actually retrying the request.
Fix
Replace
.Secondswith.TotalSecondsand.Millisecondswith.TotalMilliseconds.Tests
Added two regression tests:
RetryWorksWithTimeoutGreaterThanOrEqualTo60Seconds— verifies that a 60s timeout correctly retries on 429 instead of throwingTimeoutMessageShowsCorrectMillisecondsForLargeTimeouts— verifies the error message reports the correct total milliseconds