fix(util-retry): detect throttling from RetryErrorInfo.errorType in DefaultRateLimiter#1885
Open
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
Open
Conversation
…efaultRateLimiter The AdaptiveRetryStrategy passes a RetryErrorInfo object to DefaultRateLimiter.updateClientSendingRate(), but the rate limiter was calling isThrottlingError() directly on it. isThrottlingError() expects an SdkError with $metadata, $retryable, and name properties, none of which exist on RetryErrorInfo. This meant isThrottlingError() always returned false, so the rate limiter was never enabled. The fix adds a private isThrottlingResponse() method that first checks for RetryErrorInfo.errorType === 'THROTTLING', and falls back to isThrottlingError() for backward compatibility with the deprecated middleware-retry AdaptiveRetryStrategy. Fixes smithy-lang#1328
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.
Issue #, if available:
Fixes #1328
Description of changes:
DefaultRateLimiter.updateClientSendingRate()callsisThrottlingError(response)to decide whether to enable client-side throttling. However, theAdaptiveRetryStrategyin@smithy/util-retrypasses aRetryErrorInfoobject — not anSdkError. SinceRetryErrorInfohas none of the propertiesisThrottlingErrorchecks ($metadata,$retryable,name), the call always returnsfalseand the rate limiter is never enabled, completely defeating adaptive retry.The fix adds a private
isThrottlingResponse()method that checks forRetryErrorInfo.errorType === "THROTTLING"first, and falls back toisThrottlingError()whenerrorTypeis absent. This preserves backward compatibility with the deprecatedAdaptiveRetryStrategyin@smithy/middleware-retry, which passes a raw HTTP response.Tests added:
errorTypeis"THROTTLING"errorTypeisThrottlingErrorwhenerrorTypeis presentisThrottlingErrorwhenerrorTypeis absentBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.