Skip to content

[deploy-helpers] respect Retry-After during asset uploads - #15632

Merged
petebacondarwin merged 1 commit into
mainfrom
fix/asset-upload-retry-after
Oct 7, 2026
Merged

petebacondarwin merged 1 commit into
mainfrom
fix/asset-upload-retry-after

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Partially addresses #15060.

The fetch layer exposes Retry-After as APIError.retryAfterMs, but static asset uploads ignored it and retried using short local delays. A response such as Retry-After: 120 could therefore be retried after only a few seconds while the asset service was asking the client to pause.

This change pauses retries and queued upload requests until the latest outstanding Retry-After deadline, giving that deadline precedence over local backoff. Both queues are paused before the failed request releases its limiter slot. A request-level limiter keeps simultaneous gateway retries at concurrency one, then restores capacity gradually after successful uploads. Long deadlines use safe timer slices to avoid Node's large-setTimeout clamp.

If an upload exhausts its retries, the session cancels queued work, aborts active requests, and clears retry timers. Late responses cannot restart the failed deployment or keep the CLI alive with a new Retry-After timer.

The tests simulate a 120-second directive without waiting in real time. They verify that failed requests and queued assets stay paused, queued gateway retries remain serialized, concurrency recovers, and terminal failures cancel pending work without scheduling late retries.

Validation: Wrangler asset tests (52/52), deploy-helpers tests (246/246), both packages' source and test typechecks, oxfmt, and oxlint passed using Node 22.22.1 and pnpm 10.33.0.

Scope: this covers Workers static asset upload requests handled by syncAssets(). Retry handling for the initial assets-upload-session request and the separate Pages /pages/assets/upload path is unchanged.


  • 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: This changes internal retry scheduling and adds no public configuration or API.

Note

This is a contribution from an AI agent: OpenAI Codex (GPT-5).


Devin Review

@changeset-bot

changeset-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 82ff150

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

This PR includes changesets to release 5 packages
Name Type
@cloudflare/deploy-helpers Patch
wrangler Patch
@cloudflare/remote-bindings Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin 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

@ask-bonk

ask-bonk Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15632

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@15632

@cloudflare/config

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

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@15632

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15632

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@15632

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@15632

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 82ff150

@petebacondarwin
petebacondarwin force-pushed the fix/asset-upload-retry-after branch from e6494f9 to a3bf57a Compare September 13, 2026 12:46
devin-ai-integration[bot]

This comment was marked as resolved.

Base automatically changed from fix/asset-upload-concurrency-recovery to main September 14, 2026 12:52
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team September 14, 2026 12:53
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/calm-assets-retry.md: [@cloudflare/wrangler]
  • .changeset/warm-assets-recover.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/deploy/helpers/assets.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/deploy/assets.test.ts: [@cloudflare/wrangler]

@petebacondarwin
petebacondarwin force-pushed the fix/asset-upload-retry-after branch from eaab2b4 to 82ff150 Compare October 7, 2026 09:41
@workers-devprod

workers-devprod commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🙂

@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 Oct 7, 2026
@petebacondarwin
petebacondarwin merged commit 85b14e7 into main Oct 7, 2026
59 of 61 checks passed
@petebacondarwin
petebacondarwin deleted the fix/asset-upload-retry-after branch October 7, 2026 10:26
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 11, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `wrangler` | 4.148.0 | 4.149.0 | minor |

## Release Notes

<details>
<summary><b>wrangler</b> (4.148.0 → 4.149.0)</summary>

### Minor Changes

- [#16036](cloudflare/workers-sdk#16036)
[`9a58244`](cloudflare/workers-sdk@9a58244)
Thanks [@<!---->edevil](https://github.com/edevil)! - Support temporary
event accounts in R2 and Containers commands

`wrangler r2` and `wrangler containers` commands now accept the hidden
`--temporary` flag, so accounts created for an event can manage buckets,
objects and containers directly. Every command that supports
`--temporary` now also accepts a hidden `--event-code` flag, so the
first command a participant runs can create the event account:

  `wrangler r2 bucket create my-bucket --temporary --event-code <code>`

R2 and Containers are only available on event accounts. R2 custom
domains, Sippy, external container registries and `wrangler
cloudchamber` commands still require a logged-in account.

### Patch Changes

- [#16139](cloudflare/workers-sdk#16139)
[`2d1d563`](cloudflare/workers-sdk@2d1d563)
Thanks [@<!---->cpojer](https://github.com/cpojer)! - Update esbuild to
0.28.2

Align esbuild dependency with tooling using the latest 0.28 patch so
package managers can share one installation instead of downloading a
second native binary.

- [#15632](cloudflare/workers-sdk#15632)
[`85b14e7`](cloudflare/workers-sdk@85b14e7)
Thanks [@<!---->petebacondarwin](https://github.com/petebacondarwin)! -
Honor Retry-After directives during static asset uploads

Static asset uploads now pause retries and pending uploads until the
latest outstanding deadline requested by the API. A per-request limiter
also keeps gateway retries at the reduced concurrency after the pause
ends, preventing a deployment from immediately overloading a constrained
asset service again.

- [#16098](cloudflare/workers-sdk#16098)
[`fe607f9`](http

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.149.0)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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