Skip to content

Response body unreadable ('internal error') when Container DO is called via service binding from another worker #161

@seawatts

Description

@seawatts

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.

// 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions