cloudflare / cloudflare/workerd

Explicit regional placement disables WebSocket permessage-deflate while Smart Placement works

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

Description

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

Workers Runtime

## What versions & operating system are you using?

- Wrangler: 4.85.1
- OS: Linux

## Please provide a link to a minimal reproduction

I can provide a stripped repro if needed, but the key finding is that the only variable required to trigger this is Worker placement mode.

I reproduced it with:
- the stock Cloudflare Agents starter
- our real Worker app (`aidan-agent`)

## Describe the bug

WebSocket `permessage-deflate` negotiation works normally when a Worker has either:

- no `placement` configured, or
- Smart Placement enabled with:

```json
"placement": { "mode": "smart" }
```

But if I switch the Worker to an explicit regional placement pin:

```json
"placement": { "region": "aws:eu-west-2" }
```

then the WebSocket upgrade still succeeds with `101 Switching Protocols`, but `Sec-WebSocket-Extensions` disappears from the response.

So this is **not** a generic websocket compression failure. It appears to be specifically tied to **explicit regional placement**.

## Exact observed behaviour

### No placement configured
- `101 Switching Protocols`
- `Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits=15`

### Smart Placement
- `101 Switching Protocols`
- `Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits=15`

### Explicit regional placement (`aws:eu-west-2`)
- `101 Switching Protocols`
- `Sec-WebSocket-Extensions` header missing

## Steps to reproduce

1. Deploy a Worker that upgrades a request to a WebSocket.
2. Probe the same WebSocket endpoint with a request offering `permessage-deflate`.
3. Confirm that compression is negotiated when:
- `placement` is omitted, and
- `placement.mode = "smart"`
4. Change only the placement config to:

```json
"placement": { "region": "aws:eu-west-2" }
```

5. Redeploy.
6. Probe the same endpoint again.
7. Observe that the upgrade still returns `101`, but `Sec-WebSocket-Extensions` is no longer present.

## Expected behaviour

If the runtime supports websocket compression for this Worker, changing placement mode should not silently disable `permessage-deflate` negotiation.

## Actual behaviour

An explicit region pin appears to disable websocket compression negotiation, while Smart Placement and no placement do not.

## Extra context

- I originally discussed this with Sunil Pai on Discord, so cc @threepointone.
- There is already a broader issue about `permessage-deflate` not being accepted in some cases, but this report is narrower: the trigger here is specifically the **explicit placement pin**.
- As a workaround, we switched our production path to Smart Placement and compression immediately came back.

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.