responseStreamDisconnected errors when making 6+ sub requests in worker
We are using
We even disabled
ctx.waitUntil()
API to make sub requests to send metrics/logs to DataDog, and when there are 6 or more requests, the request/response that is being returned is truncated. When looking at real-time worker logs, the outcome field is set to "outcome": "responseStreamDisconnected",
. There are no other errors that are present.
The format we are using to send metrics is ctx.waitUntil(async function() { return await fetch(...)});
. The individual requests all function correctly, and I can reproduce this error by enabling any one of them, but if they are all enabled together, an error occured.
We have the following wrangler.toml
config:
and we're on "wrangler": "4.7.2"
.We even disabled
ctx.passThruOnException
to see if we can surface an error, but nothing shows up.6 Replies
waitUntil only lasts 30 seconds, my guess is that this is taking longer than 30 seconds and is cancelling the inflight request
This all happens in actually happens in less than 1 second. I've attached a CF log (with some fields redacted)
I should mention that when this behavior happens, it totally breaks the HTML page we are serving (we putting workers in front of nextJS applications)
I am suspicious of the limit documented here - https://developers.cloudflare.com/workers/platform/limits/#simultaneous-open-connections -

can you share your code?
Top level entry:
Top Level Handler:
In the above issue-
const response = await fetchOrigin(request, env);
this response is the one that is truncated. It's going to be the first outbound subrequest from the worker
Typically, in the additional outgoing requests, the function signature passed to ctx.waitUntil
is pretty consistent, it's an async function that returns await fetch(...)
so that the promise returned to waitUntil
is from the fetch function
request/response
objects are passed around to make logging properties of those objects convienent, but nothing is reading / consuming requests for the sake of these requests, just reading headers.
I also raised a support ticket to look at this issue, in case its something specific to our account