cloudflare / cloudflare/workers-sdk

🐛 BUG: PUT request with Expect header not properly handled

Open
#7,185 0 comments 0 reactions 0 assignees View on GitHub
upstream:workerd
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### Which Cloudflare product(s) does this pertain to?

Workers Runtime, Wrangler

### What version(s) of the tool(s) are you using?

3.85.0 [Wrangler]

### What version of Node are you using?

10.5.0[npm], v20.12.2[Node.js]

### What operating system and version are you using?

Mac Sonoma 14.7.1

### Describe the Bug

### Context

We are using a cloudflare worker as a proxy in front of a backend.

That backend can receive PUT requests with the [Expect header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect) set.

This is used, for example, by mvn commands when uploading files. See this [section](https://svn.apache.org/repos/infra/websites/staging/maven/trunk/content//guides/mini/guide-http-settings.html#The_Basics) from the Maven documentation.

### Observed behavior

The backend will correctly return the `100 Continue` response code in order to receive the request body.

It seems that the worker "interprets" the `100 Continue` response code as "the response has been sent". Thus, trying to read the request body after that ends up in an error (the backend will hit an unexpected EOF).

### Expected behavior

The `100 Continue` response code should not be considered as "the response has been sent" as the client will follow up with the request body.

### Steps to reproduce

Follow the steps that are described in: https://github.com/10io/wrangler-expect-header.

### Please provide a link to a minimal reproduction

https://github.com/10io/wrangler-expect-header

### Please provide any relevant error logs

```
[wrangler:inf] PUT /dummy.txt 503 Service Unavailable (2ms)
✘ [ERROR] Uncaught (async) TypeError: Can't read from request stream after responding with an exception.
```

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproduction at github.com/10io/wrangler-expect-header and reproduce the PUT request using an Expect header. Read the linked HTTP 100 Continue and Maven documentation, then trace how Workers Runtime and Wrangler handle the interim response and request body. Done means the backend receives the complete body after 100 Continue without the request stream error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.