New error in edge function when calling response.text()

I’ve just started to see errors in my edge function. These aren’t caused by a deployment, so it seems something changed in edge functions themselves or the response payloads they receive.

The error is:

TypeError: request or response body error: error reading a body from connection: stream error received: not a result of an error
    at readableStreamCollectIntoUint8Array (ext:deno_web/06_streams.js:869:28)
    at InnerBody.consume (ext:deno_fetch/22_body.js:160:14)
    at consumeBody (ext:deno_fetch/22_body.js:239:34)
    at OriginResponse.text (ext:deno_fetch/22_body.js:318:16)
    at addHtmlSecurityHeaders (file:///root/netlify/edge-functions/add-html-security-headers.js:12:33)
    at eventLoopTick (ext:core/01_core.js:183:11)
    at async FunctionChain.runFunction (file:///root/src/bootstrap/function_chain.ts:390:22)
    at async (file:///root/src/bootstrap/function_chain.ts:310:20)
    at async handleRequest (file:///root/src/bootstrap/handler.ts:80:22)
    at async Server.#respond (

It appears to be triggered by this line in my code, which was working fine until now. It may be that the response is bodiless, but that would be new behaviour (and I’m not in a position to dig much right now).

Did something change to cause this?

Some more information. When I log the status code and request URL, I get this when a request is made to /:


I have the edge function in manual cache mode, so I guess maybe that broke? Please note, this is not a problem with my edge function (as I understand them). Something changed in how they’re run. My site has been down for several hours now, and I’d rather not bypass this function.

After more than five hours this is still broken. I removed the edge function and rearranged my site to generate a _headers file at build time.

Sorry to hear about the trouble! I’ve referred this to our devs for their advice.

Hi @qubyte! We’ve looked into this and found the root cause. Deploying a fix now, i’ll ping back here when that’s fully rolled out.

Thank you for bringing this to our attention. We should’ve caught this bug earlier, and i’m sorry it brought your site down for multiple hours.

The fix is fully rolled out now. Please let me know if the issue persists.

This is really a major safety accident!
My website has finally been restored!!

I’ve marked as complete, but I’m afraid I can’t verify. I switched to templating a _headers file into my public directory instead. Edge functions have proven to have too many edge cases for me!

Glad your site has been restored!