🐛 BUG: getPlatformProxy R2 body stream fails under Bun: responseDispatcher.close is not a function
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 66/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, javascript, node.js, typescript
Research direction
Start with the synchronous-fetch worker in miniflare's dist/src/index.js, where the issue reports responseDispatcher.close() is called after a ReadableStream result. Reproduce with the provided three-file setup under Bun using bun install && bun t.ts, then compare with Node. Done when the R2 body stream reads successfully under Bun and the existing Node behavior still works.
Written by the indexing model from the issue text.
Description
What versions & operating system are you using?
- wrangler 4.168.0 (miniflare 5.20261123.1-beta); also reproduces on wrangler 4.165.0 (miniflare 5.20261118.0-beta)
- Bun 1.4.2
- Linux 6.12 (Debian 13, x86_64)
- Works under Node 22.23.5 with the same files
Please provide a link to a minimal reproduction
Inline, three files in an empty directory:
package.json
{ "name": "r2t", "private": true, "dependencies": { "wrangler": "4.168.0" } }
wrangler.jsonc
{ "name": "r2t", "main": "w.js", "compatibility_date": "2026-11-01", "r2_buckets": [{ "binding": "B", "bucket_name": "test-bucket" }] }
w.js
export default {}
t.ts
import { getPlatformProxy } from "wrangler";
const p = await getPlatformProxy<{ B: any }>({ persist: false });
await p.env.B.put("k", "hello stream");
const o = await p.env.B.get("k");
try { console.log("streamed:", await new Response(o.body).text()); } catch (e) { console.log("FAIL:", (e as Error).stack); }
await p.dispose();
Run bun install && bun t.ts. Under Node (node t.mts, same code without the type annotations) it prints streamed: hello stream.
Describe the Bug
Reading an R2 object's body stream through getPlatformProxy fails under Bun. arrayBuffer() / text() on the same object work, so only the ReadableStream result path is affected.
The cause looks like the synchronous-fetch worker in miniflare's dist/src/index.js: after a ReadableStream result it retires the pool with void responseDispatcher.close().catch(() => {}). Under Bun, the undici Pool it creates has no close() method, so this throws a TypeError synchronously. The .catch doesn't help because the call itself throws before a promise exists. Guarding the call (responseDispatcher?.close?.()), or wrapping it in a try/catch, would probably be enough.
Please provide any relevant error logs
FAIL: TypeError: responseDispatcher.close is not a function. (In 'responseDispatcher.close()', 'responseDispatcher.close' is undefined)
at <anonymous> (blob:edf7a7d1-1ecf-46e0-9398-0c83d7a44270:47:31)
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 1.7k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 282
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cloudflare/workers-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
cloudflare/workers-sdk#17215 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
cloudflare/workers-sdk#17189 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/workers-sdk#17187 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
cloudflare/workers-sdk#17175 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
cloudflare/workers-sdk#17174 ·
Maintainers usually reply within 1 day
All issues in cloudflare/workers-sdk
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
earendil-works/pi#12615 ·
Maintainers usually reply within 1 day
-
My Caps shows "Shared" on private Caps that were never sharedPossibly taken @AksharP5 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CapSoftware/Cap#4569 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3749 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Flagsmith/flagsmith-nodejs-client#332 ·
Maintainers usually reply within 2 days