cloudflare / cloudflare/workerd

🐛 Bug Report — Runtime APIs: successive `fetch()`es fail if upstream doesn't consume body

Open
#1,741 2 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

Hey! 👋 When investigating cloudflare/workers-sdk#5095, we observed `Network connection lost` errors from successive calls to `fetch()` if the upstream didn't consume the request body. Specifically, every other request would fail. See https://github.com/mrbbot/workerd-network-connection-lost-repro for a minimal reproduction. Uncommenting this line https://github.com/mrbbot/workerd-network-connection-lost-repro/blob/04b2a464c8c269fb467ca5247efbb6da2303c9f5/user.capnp#L19 "fixes" the issue. It also seems like this line https://github.com/mrbbot/workerd-network-connection-lost-repro/blob/04b2a464c8c269fb467ca5247efbb6da2303c9f5/index.mjs#L32 needs to create a body with at least `2**16 + 1` bytes to trigger a reproduction.

This issue feels related to https://github.com/cloudflare/workerd/issues/1376 and https://github.com/cloudflare/workerd/issues/960. In https://github.com/cloudflare/workerd/issues/960#issuecomment-1663042638, it was suggested that `workerd` should be canceling the upload in cases where a response is returned without reading the body. It feels like the same thing should be happening here.

/cc @petebacondarwin @RamIdeas

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.