`wrangler r2 bulk put`: retry transient failures, and report what was uploaded when the command fails

Aperta
#17,136 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
cli

Direzione di ricerca

Start in packages/wrangler/src/r2/object.ts at the r2 bulk put handler: read how the PQueue is built and how queue.addAll(...) is awaited, then read putRemoteObject in packages/wrangler/src/r2/helpers/object.ts for the single fetch. Look at the existing r2 tests under packages/wrangler/src/__tests__/r2 to see how uploads are mocked, and run them before changing anything. Done means each upload retries with backoff on network/429/5xx, the queue stops starting new work on a final failure while draining in-flight tasks, progress prints after completion, and the exit summary lists uploaded, failed and not-attempted keys.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

wrangler r2 bulk put stops at the first failed upload. It does not retry that upload, it does not wait for the uploads that are still running, and the error names only the one file that failed. After a failure, the user cannot tell which objects are in the bucket without listing it.

This is a request for two changes:

  1. Retry a failed upload a few times before giving up, at least for network errors, 429 and 5xx responses.
  2. When an upload fails for good, let the in-flight uploads finish, then print how many objects were uploaded and which ones failed or were never started.
What happens today

The code is in packages/wrangler/src/r2/object.ts (the r2 bulk put handler) and packages/wrangler/src/r2/helpers/object.ts (putRemoteObject).

  • Each upload is one fetch with no retry.
  • Each upload is a PQueue task that rethrows its error as a FatalError. The handler awaits queue.addAll(...), which rejects as soon as one task rejects. The process then exits while the other tasks are still running.
  • The progress line (Uploaded 33% (20 out of 60)) is printed when an upload starts, not when it finishes, so it overstates what was stored.
Reproduction

Tested with wrangler 4.77.0 on macOS, Node 24.14. The code paths above are unchanged on main as of Nov. 23, 2026.

  1. Create an empty bucket.
  2. Write a list of 60 entries, each a 256 KiB file. Make one entry in the first 20 fail: I gave entry 5 a key of 1,100 characters, which the API rejects with 400.
  3. Run wrangler r2 bulk put <bucket> --filename list.json --remote (default concurrency of 20).
  4. List the bucket.

Result over three runs:

Run Exit code Time to exit In-flight uploads stored (of 19) Entries never started (of 40)
1 1 0.6 s 12 40
2 1 0.7 s 17 40
3 1 0.7 s 19 40

The output in every run was the same: Uploaded 33% (20 out of 60), then an error naming entry 5 only. The same list without the failing entry uploads 60 of 60 and exits 0.

So one rejected object out of 60 left the bucket with 12, 17 or 19 objects, and nothing in the output says which.

Why it matters
  • Whether an abandoned upload is stored depends on how far its request had got when the process exited. The result differs from run to run.
  • A single transient error fails the whole run. Bulk uploads of thousands of objects hit one sooner or later. See #12687 and #12413, where a fetch failed or a 503 partway through ended the command.
  • Re-running the command is the only recovery, and it uploads everything again.
Suggested behavior
  • Retry each upload up to a small fixed number of times with backoff, for network errors, 429 and 5xx.
  • On a final failure, stop starting new uploads, wait for the in-flight ones, and exit non-zero with a summary: objects uploaded, objects failed (with the error for each), objects not attempted.
  • Print progress when an upload finishes.
Lingua principale
TypeScript
Stelle
4.7k
Fork
1.7k
Merge medio
1g 22h
PR unite (30g)
282

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cloudflare/workers-sdk

Tutte le issue di cloudflare/workers-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.