WebSocketRefusal
class WebSocketRefusalAn 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.
How you get one
Section titled “How you get one”new WebSocketRefusal(code, reason?)
Constructor
Section titled “Constructor”new WebSocketRefusal(code: number, reason?: string): WebSocketRefusalcode number
reason? string
Properties
Section titled “Properties”code: numberThe close code sent to the client: 1000, or an application code in 3000-4999.
reason
Section titled “reason”reason: stringThe close reason sent to the client: at most 123 bytes of UTF-8 (the wire’s control-frame limit).
Learn: Overview