Skip to content

fix(ws): normalize reserved close codes in proxy#368

Open
asdaxzcwqsa wants to merge 3 commits into
cloudflare:mainfrom
asdaxzcwqsa:fix/ws-close-code-normalization
Open

fix(ws): normalize reserved close codes in proxy#368
asdaxzcwqsa wants to merge 3 commits into
cloudflare:mainfrom
asdaxzcwqsa:fix/ws-close-code-normalization

Conversation

@asdaxzcwqsa

Copy link
Copy Markdown

Summary

  • normalize outbound WebSocket close codes before forwarding them across the proxy
  • map reserved/invalid close codes like 1006 to a valid fallback (1011)
  • add focused tests covering valid and reserved close-code handling

Problem

The proxy was forwarding peer close codes directly with ws.close(event.code, ...). Reserved codes such as 1006 are not valid in outbound close frames, so forwarding them throws at runtime and can leave proxy handling stuck.

Notes

This keeps the existing close-reason behavior intact and only normalizes the close code before sending it onward.

Fixes #260

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebSocket proxy throws when forwarding reserved close code 1006

1 participant