Skip to content

Comments

fix(util-retry): detect throttling from RetryErrorInfo.errorType in DefaultRateLimiter#1885

Open
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
TrevorBurnham:fix/default-rate-limiter-throttle-detection
Open

fix(util-retry): detect throttling from RetryErrorInfo.errorType in DefaultRateLimiter#1885
TrevorBurnham wants to merge 1 commit intosmithy-lang:mainfrom
TrevorBurnham:fix/default-rate-limiter-throttle-detection

Conversation

@TrevorBurnham
Copy link
Contributor

Issue #, if available:

Fixes #1328

Description of changes:

DefaultRateLimiter.updateClientSendingRate() calls isThrottlingError(response) to decide whether to enable client-side throttling. However, the AdaptiveRetryStrategy in @smithy/util-retry passes a RetryErrorInfo object — not an SdkError. Since RetryErrorInfo has none of the properties isThrottlingError checks ($metadata, $retryable, name), the call always returns false and the rate limiter is never enabled, completely defeating adaptive retry.

The fix adds a private isThrottlingResponse() method that checks for RetryErrorInfo.errorType === "THROTTLING" first, and falls back to isThrottlingError() when errorType is absent. This preserves backward compatibility with the deprecated AdaptiveRetryStrategy in @smithy/middleware-retry, which passes a raw HTTP response.

// Before — always false for RetryErrorInfo
if (isThrottlingError(response)) {

// After — checks errorType first, falls back to isThrottlingError
if (this.isThrottlingResponse(response)) {

private isThrottlingResponse(response: any): boolean {
  if (response?.errorType) {
    return response.errorType === "THROTTLING";
  }
  return isThrottlingError(response);
}

Tests added:

  • Enables rate limiter when errorType is "THROTTLING"
  • Does not enable rate limiter for non-throttling errorType
  • Does not call isThrottlingError when errorType is present
  • Falls back to isThrottlingError when errorType is absent

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…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
@TrevorBurnham TrevorBurnham requested a review from a team as a code owner February 21, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefaultRateLimiter is never enabled due to type confusion

1 participant