cloudflare / cloudflare/workerd
TypedArray and ArrayBuffer bodies must be cloned instead of taking a reference
Open
wpt-conformance
- Dominant language
- C++
- Stars
- 8.7k
- Forks
- 739
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 174
Description
See `fetch/api/body/cloned-any.js`:
```js
const body = new Uint8Array([97]); // a
const res = new Response(body);
const req = new Request(url, { method, body });
body[0] = 98; // b
assert_true(await res.text() === 'a');
assert_true(await req.text() === 'a');
```
We have a problem: We're only taking a reference to `body`, and so we end up with `res.text() === 'b'` etc.
Fixing this will probably require a compat flag. To do this efficiently, we might consider copy-on-write.
Contributor guide
Assessment
This issue has not been assessed yet.