Skip to content

[wrangler] Respect and surface 429 errors from HTTP requests - #14877

Merged
NuroDev merged 1 commit into
cloudflare:mainfrom
jasoncabot:jcabot/retry-after-header-for-wrangler
Jul 28, 2026
Merged

[wrangler] Respect and surface 429 errors from HTTP requests#14877
NuroDev merged 1 commit into
cloudflare:mainfrom
jasoncabot:jcabot/retry-after-header-for-wrangler

Conversation

@jasoncabot

@jasoncabot jasoncabot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The Cloudflare API returns 429 errors with a rate limit header called https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Retry-After

This isn't always set - but in certain cases it is. When it is available we should follow it up to a certain limit to avoid waiting / blocking for too long. I set the limit to be up to a maximum of 60s for now (open to suggestions here). When reaching 60s the request will fail with the original error.

I kept the isRetryable returning false for 429 errors in case there was any existing clients as APIError is exported from the public @cloudflare/workers-utils package. If a caller was doing (err.isRetryable()) retryNow() with no backoff it would send another request immediately, making more of a mess. So I put the handling code in the one place that could handle this backoff properly.

a robin making a pull request
  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Internal error handling improvements not worth documenting.

@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8f20ad3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@cloudflare/workers-utils Minor
wrangler Minor
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch
@cloudflare/workers-auth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/wrangler/src/core/handle-errors.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14877

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@14877

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14877

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14877

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14877

miniflare

npm i https://pkg.pr.new/miniflare@14877

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14877

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14877

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14877

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14877

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14877

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14877

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14877

wrangler

npm i https://pkg.pr.new/wrangler@14877

commit: 8f20ad3

@jasoncabot
jasoncabot force-pushed the jcabot/retry-after-header-for-wrangler branch 3 times, most recently from 0ca7054 to fb9dfa2 Compare July 28, 2026 09:33
@jasoncabot
jasoncabot marked this pull request as ready for review July 28, 2026 09:34
@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team July 28, 2026 09:34
@workers-devprod

workers-devprod commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@NuroDev
NuroDev requested review from NuroDev and removed request for edmundhung July 28, 2026 10:19
Comment thread packages/workers-utils/src/cfetch/index.ts Outdated
Comment thread packages/workers-utils/src/retry.ts Outdated
Comment thread packages/workers-utils/src/retry.ts Outdated
@jasoncabot
jasoncabot force-pushed the jcabot/retry-after-header-for-wrangler branch from 0e5d988 to d8cff6a Compare July 28, 2026 15:26
@jasoncabot
jasoncabot force-pushed the jcabot/retry-after-header-for-wrangler branch from d8cff6a to 8f20ad3 Compare July 28, 2026 15:28

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jul 28, 2026
@NuroDev
NuroDev enabled auto-merge (squash) July 28, 2026 15:48
@NuroDev
NuroDev merged commit 552bcfc into cloudflare:main Jul 28, 2026
59 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jul 28, 2026
@jasoncabot
jasoncabot deleted the jcabot/retry-after-header-for-wrangler branch July 28, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants