WebSocket proxy throws when forwarding reserved close code 1006

Author: iori0311Created Feb 16, 2026Updated Jun 24, 2026

When the proxy receives a close event with code 1006 (or other reserved codes), it forwards that code with ws.close(event.code, event.reason).

This throws at runtime: TypeError: Invalid WebSocket close code: 1006

What I observed:

  • one side of the WebSocket closed with code 1006
  • proxy tried to forward 1006 directly
  • request handling hung after the exception

Expected behavior:

  • reserved close codes are not sent in outbound close frames
  • proxy closes with a valid fallback code instead

Related PR: #259