Skip to content

fix: buffer current.body to ArrayBuffer before putVersion to survive SDK retries - #268

Merged
kptdobe merged 1 commit into
mainfrom
fix/putversion-stream-body
Apr 29, 2026
Merged

kptdobe merged 1 commit into
mainfrom
fix/putversion-stream-body

Conversation

@kptdobe

@kptdobe kptdobe commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • putVersion received current.body (a live R2 ReadableStream from getObject) as the Body of PutObjectCommand
  • The AWS SDK retries on network failures using the same body — but a ReadableStream can only be consumed once
  • On SDK internal retry, Cloudflare throws "An error was encountered in a non-retryable streaming request.", causing putVersion to return 500 and postObjectVersionWithLabel to return 500 instead of 201
  • Observed in production logs: 5 /versionsource/ 500 errors on the new script version after PR fix: consumed body on retry #264 was deployed (PR fix: consumed body on retry #264 fixed update.body but not current.body)

Fix: buffer current.body to ArrayBuffer immediately after getObject in putObjectWithVersion, before it is passed to putVersion. An ArrayBuffer can be reused freely across retries.

Test plan

  • New regression test: returns 201 when version client body is a ReadableStream that would be disturbed by SDK retry — mock ifNoneMatch client throws if it receives a ReadableStream, passes with ArrayBuffer
  • All 366 existing tests pass

🤖 Generated with Claude Code

…SDK retries

putVersion passes current.body (a ReadableStream from getObject) to
PutObjectCommand. The AWS SDK retries on network failures with the same
stream — but a ReadableStream can only be consumed once. Cloudflare throws
"An error was encountered in a non-retryable streaming request." on the
retry, causing putVersion to fail and postObjectVersionWithLabel to return
500 instead of 201. Seen in production on /versionsource/ endpoints.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Apr 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kptdobe
kptdobe requested a review from bosschaert April 29, 2026 13:57
@kptdobe
kptdobe merged commit 47562f1 into main Apr 29, 2026
6 checks passed
@kptdobe
kptdobe deleted the fix/putversion-stream-body branch April 29, 2026 14:36
adobe-bot pushed a commit that referenced this pull request Apr 29, 2026
## [1.6.3](v1.6.2...v1.6.3) (2026-04-29)

### Bug Fixes

* buffer current.body to ArrayBuffer before putVersion to survive SDK retries ([#268](#268)) ([47562f1](47562f1))
* guard against null body in notifyCollab to prevent move partial_failure ([#267](#267)) ([b21c4eb](b21c4eb))
@adobe-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants