Workers WebSockets Auto-Reply to Close Frames
Key Points
- Automatic Close frame replies now enabled by default
- Half-open mode available for WebSocket proxying
- Backward compatible with existing close handlers
Summary
Cloudflare Workers runtime now automatically sends reciprocal Close frames when receiving Close frames from peers, matching WebSocket specification and browser behavior. This change is enabled by default for Workers using compatibility dates on or after 2026-04-07.
Key Points
- Automatic Close Handling: Workers automatically reply to Close frames and transition
readyStatetoCLOSEDbefore firing the close event - Backward Compatibility: Existing code calling
close()in close event handlers continues to work (calls are silently ignored when already closed) - Half-Open Mode: Pass
{ allowHalfOpen: true }toaccept()for WebSocket proxying scenarios where manual close coordination is needed - Compatibility Flag: Controlled by
web_socket_auto_reply_to_closecompatibility flag for dates >= 2026-04-07