cloudflare / cloudflare/workers-sdk

🐛 BUG: R2ObjectBody body `ReadableStream` not valid for put parameter

Open
#6,425 8 comments 10 reactions 0 assignees View on GitHub
product:r2 upstream:workerd
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

### Which Cloudflare product(s) does this pertain to?

R2

### What version(s) of the tool(s) are you using?

3.20240725.0

### What version of Node are you using?

20.13.1

### What operating system and version are you using?

Mac Sonoma 14.6

### Describe the Bug

### Observed behavior

```
const current = await env.BUCKET.get('source.html');
const update = await env.BUCKET.put('dest.html', current.body);
```
Raises error: `TypeError: Provided readable stream must have a known length (request/response body or readable half of FixedLengthStream)`

### Expected behavior
No error should be raised. Documentation indicates that `body` of R2ObjectBody is of type `ReadableStream`. Also that the `put` operation accepts a `ReadableStream` for the value.

### Steps to reproduce
Please provide the following:

See Gist

### Please provide a link to a minimal reproduction

https://gist.github.com/bstopp/f1f9fcdeefee94d9f1f451fa374f9273

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.