Skip to content

WebSocketRefusal

class WebSocketRefusal

An upgrade hook’s accept-then-close verdict: the handshake completes, then the connection closes immediately with this code and reason, skipping the route’s channels and controller entirely.

This is the one refusal a browser client can read: a denied handshake exposes nothing to its JavaScript (no status, no headers), while a close frame’s code and reason arrive in the close event. Redirect-on-miss is the canonical shape (an application code plus the target URL as the reason); flare owns the mechanics and the wire limits, the application owns what the code means. The pre-handshake FlareResponse denial remains the right refusal for clients that can read HTTP, such as curl or server-side clients; this one costs a completed handshake, which is what makes it readable.

new WebSocketRefusal(code, reason?)

new WebSocketRefusal(code: number, reason?: string): WebSocketRefusal

code number

reason? string

code: number

The close code sent to the client: 1000, or an application code in 3000-4999.

reason: string

The close reason sent to the client: at most 123 bytes of UTF-8 (the wire’s control-frame limit).

Learn: Overview