Skip to content

[wrangler] Retry transient failures in workflows instances list and describe - #15871

Merged
dario-piotrowicz merged 5 commits into
cloudflare:mainfrom
tw4:fix/workflows-read-retries
Oct 1, 2026
Merged

dario-piotrowicz merged 5 commits into
cloudflare:mainfrom
tw4:fix/workflows-read-retries

Conversation

@tw4

@tw4 tw4 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #15865.

wrangler workflows instances list and wrangler workflows instances describe made a single API request and exited with code 1 on a transient failure, such as a 503 or a dropped connection, even when the next request would have succeeded.

These read-only requests now go through the existing retryOnAPIFailure helper: up to 3 attempts, retrying on 5xx, 429 (honouring Retry-After), request timeouts and network errors. Persistent failures still surface once the attempts are exhausted.

  • describe: retries the instance request, and the request that resolves --id latest (the default) in getInstanceIdFromArgs, which is the first request describe makes. pause, resume, terminate, restart, send-event and delete use the same helper to resolve latest, so that lookup is retried for them too. The mutating requests those commands make afterwards are not retried.
  • list: fetchCursorPage deletes page from the URLSearchParams it receives, so each attempt gets its own copy. Without that, a retry would silently return page 1 for --page N.
  • --json: retryOnAPIFailure reports Retry-After waits with logger.info, which writes to stdout. Under --json, getRetryLogger sends these notices to stderr so stdout stays valid JSON.

A retry in list restarts the cursor walk from the first page, because fetchCursorPage has no way to resume from a cursor. This is the same root cause as #15866 and is left for that issue.

Manual testing

Point the CLI at a local server that returns 503 (optionally with Retry-After: 0) or drops the connection on the first request and succeeds on the next, for example via CLOUDFLARE_API_BASE_URL, then run:

  • wrangler workflows instances list <name> --json
  • wrangler workflows instances list <name> --page 2 --json
  • wrangler workflows instances describe <name> --json

Each command should succeed and print only JSON on stdout.


  • 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 fixes the reliability of existing commands and does not change their documented flags or output.

Devin Review

@changeset-bot

changeset-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2cbe123

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

This PR includes changesets to release 3 packages
Name Type
wrangler 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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Sep 25, 2026
@workers-devprod
workers-devprod requested review from a team and dario-piotrowicz and removed request for a team September 25, 2026 12:34
@workers-devprod

workers-devprod commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/workflows-read-retries.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/workflows.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/workflows/commands/instances/delete.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/workflows/commands/instances/describe.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/workflows/commands/instances/list.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/workflows/utils.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

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

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 2cbe123

@tw4

tw4 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

The two failing CI jobs look unrelated to this change. This PR only touches packages/wrangler/src/workflows/, workflows.test.ts and a changeset.

  • Tests (macOS, fixtures): @fixture/start-worker-node failed with bind(): Address already in use (os error 48), which is a port collision on the runner.
  • Tests (Windows, packages-and-tools): two tests in LocalRuntimeController.test.ts (should persist cached data and should not persist data when persist is false) timed out with Timed out waiting for reloadComplete. I reproduced should persist cached data failing locally on Windows against current main (1c5b0f5) without this change, so it isn't caused by this PR.

I don't have permission to rerun the jobs from a fork. Could a maintainer rerun the failed jobs when convenient? Thanks!

@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.

Thanks @tw4 for this fix! 🙏

The changes here look good to me but as I suggested I would rename the new utility and add dedicated unit tests for it, could you have a go at it? 🙏

@workers-devprod

workers-devprod commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

Comment thread .changeset/workflows-read-retries.md Resolved
@dario-piotrowicz

Copy link
Copy Markdown
Member

@tw4 the two red CI jobs keep failing, could you rebase your branch to make sure that this aren't due to your branch being out-of-sync with main?

tw4 and others added 5 commits October 1, 2026 15:30
…escribe

A single 5xx response or dropped connection made these read-only commands
fail even when the next request would succeed. Route their reads, and the
read that resolves `--id latest`, through the existing retryOnAPIFailure
helper. Each attempt gets its own copy of the query params because
fetchCursorPage deletes `page` from them, and under --json retry notices go
to stderr so stdout stays valid JSON.
delete built its own args object for getInstanceIdFromArgs and dropped
`json`, so a Retry-After notice could land on stdout ahead of the JSON
result. Make `json` a required key so callers can't omit it silently.
Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com>
Co-authored-by: Dario Piotrowicz <dario.piotrowicz@gmail.com>
@tw4
tw4 force-pushed the fix/workflows-read-retries branch from 48df2a2 to 2cbe123 Compare October 1, 2026 12:40
@tw4

tw4 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@dario-piotrowicz thanks for the review! I've rebased the branch on the latest main and pushed. CI should now show whether the two red jobs are related to this branch.

I also addressed your review:

  • Rename: your suggestion renamed only the definition, so I updated the remaining callers in describe.ts, list.ts and getInstanceIdFromArgs to use getJsonAwareRetryLogger.
  • Unit tests: added packages/wrangler/src/__tests__/workflows-utils.test.ts with dedicated tests for the utility. They check that it returns the shared logger when json is off, sends info/log to stderr when json is on, and keeps stdout empty under --json.

@dario-piotrowicz

Copy link
Copy Markdown
Member

@dario-piotrowicz thanks for the review! I've rebased the branch on the latest main and pushed. CI should now show whether the two red jobs are related to this branch.

I also addressed your review:

  • Rename: your suggestion renamed only the definition, so I updated the remaining callers in describe.ts, list.ts and getInstanceIdFromArgs to use getJsonAwareRetryLogger.
  • Unit tests: added packages/wrangler/src/__tests__/workflows-utils.test.ts with dedicated tests for the utility. They check that it returns the shared logger when json is off, sends info/log to stderr when json is on, and keeps stdout empty under --json.

Great! Thank you very much! 🙏

Let's ship this! 😄

@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

@dario-piotrowicz
dario-piotrowicz merged commit 6a4b0fe into cloudflare:main Oct 1, 2026
57 checks passed
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 5, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `wrangler` | 4.146.0 | 4.147.0 | minor |

## Release Notes

<details>
<summary><b>wrangler</b> (4.146.0 → 4.147.0)</summary>

### Minor Changes

- [#15928](cloudflare/workers-sdk#15928)
[`7f57b1c`](cloudflare/workers-sdk@7f57b1c)
Thanks [@<!---->ichernetsky-cf](https://github.com/ichernetsky-cf)! -
Allow `"us"` as a jurisdiction for Container applications

Container placement constraints now accept `constraints.jurisdiction:
"us"` in Wrangler and typed Cloudflare configuration. This makes the US
jurisdiction available alongside `"eu"` and `"fedramp"`.

### Patch Changes

- [#15974](cloudflare/workers-sdk#15974)
[`7f700ef`](cloudflare/workers-sdk@7f700ef)
Thanks [@<!---->martinezjandrew](https://github.com/martinezjandrew)! -
Fix `wrangler containers list` to report live instances

The `LIVE INSTANCES` column now reports each application's active
runtime instances instead of its configured instance count, matching the
Cloudflare dashboard. JSON output continues to expose the configured
count through the existing `instances` field.

- [#15980](cloudflare/workers-sdk#15980)
[`90e6a1b`](cloudflare/workers-sdk@90e6a1b)
Thanks [@<!---->martinezjandrew](https://github.com/martinezjandrew)! -
Accept Durable Object application IDs in Containers commands

`wrangler containers instances` and `wrangler containers delete` now
accept the 32-character hexadecimal application IDs returned for Durable
Object-backed applications, in addition to legacy dashed UUIDs.

- [#15871](cloudflare/workers-sdk#15871)
[`6a4b0fe`](cloudflare/workers-sdk@6a4b0fe)
Thanks [@<!---->tw4](https://github.com/tw4)! - Retry transient API
failures in `wrangler workflows instances list` and `wrangler workflows
instances describe`

Previously, a single temporary 5xx response or dropped connection made
these read-only commands

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.147.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>
@tw4
tw4 deleted the fix/workflows-read-retries branch October 14, 2026 12:51
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.

[wrangler] Workflow list and describe fail on transient API errors without retrying

3 participants