Skip to content
Back to the playbook

Fixing "Cannot perform I/O on behalf of a different request"

Cloudflare Workersrevision 1

Diagnostic tree

  1. In progressWorker throws "Cannot perform I/O on behalf of a different request"Each Worker invocation has its own isolated execution context. Accessing a stream, Request, or Response body created in one invocation from a different invocation is disallowed and throws this error — it's the runtime protecting request isolation, not a transient failure.
View the whole map (7 more steps)
  • Look for an I/O object cached at module scope
  • Cache the data, not the I/O object
  • Check for a cached database/connection client
  • Create the client inside the handler, per request
  • No cached I/O object found — escalate
  • Send two rapid successive requests
  • Resolved

What to test

Worker throws "Cannot perform I/O on behalf of a different request"

Each Worker invocation has its own isolated execution context. Accessing a stream, Request, or Response body created in one invocation from a different invocation is disallowed and throws this error — it's the runtime protecting request isolation, not a transient failure.

What happened?