cloudflare / cloudflare/containers
Response body unreadable ('internal error') when Container DO is called via service binding from another worker
- Dominant language
- TypeScript
- Stars
- 270
- Forks
- 42
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 4
Description
## Description
When **Worker A** calls **Worker B** (which uses Cloudflare Containers) via a **service binding**, the `Response` body returned from `container.fetch()` inside Worker B's Durable Object is unreadable — it fails with an `"internal error"` message. The same container and endpoint work fine when called directly (not through a service binding).
## Reproduction
1. **Worker B** — a Cloudflare Worker with a Container-backed Durable Object that calls `this.containerFetch(url, opts)` and returns the `Response`.
2. **Worker A** — calls Worker B via a service binding: `env.WORKER_B.fetch(request)`.
3. Worker A receives a `Response` whose body cannot be read — attempting to call `.text()` or `.json()` on it yields `"internal error"`.
This does **not** happen when:
- Worker B is called directly (not via service binding)
- Both workers run locally with `wrangler dev`
## Workaround
We work around this by using a **DO RPC method** that returns plain structured-clonable data (`{ status: number, body: string }`) instead of forwarding the `Response` object. This avoids the broken `Response` body streaming at the DO → stateless worker boundary.
```typescript
// Instead of returning container.fetch() Response directly:
async processRequest(path: string, body: string): Promise<{ status: number; body: string }> {
const response = await this.containerFetch(url, { method: 'POST', body, ... });
const text = await response.text();
return { status: response.status, body: text };
}
```
## Environment
- Production (Cloudflare edge)
- `@cloudflare/containers` package
- Observed as of March 2026
## Related
- cloudflare/workers-sdk#11114 — similar issue with `Response`/`ReadableStream` not serializable over service binding RPC (scoped to local dev with `remote: true`, but likely the same underlying serialization limitation)
Contributor guide
Assessment
This issue has not been assessed yet.