Whether a WebSocket close code represents a clean, expected shutdown rather than a connection
that died.
Clean codes: 1000 (normal), 1001 (going away — a page or window navigating away or closing), 1005
(no status code was present in the close frame, which a plain close() with no arguments
produces), and INTENTIONAL_CLOSE_CODE, this codebase's own marker for a close we initiated
on purpose. What all four have in common is that a closing handshake completed. The code that
matters is 1006: no close frame was ever received, the fingerprint of a connection that died
rather than being closed — the shape a suspend produces.
Shared so the client and server close handlers cannot independently drift on which codes count as
clean. isCleanCloseEvent is the predicate to use where the event itself is in hand.
Parameters
code: unknown
code from a WebSocket close event
Returns boolean
true if the code indicates a completed closing handshake, false otherwise (including
for a non-numeric code)
Whether a WebSocket close
coderepresents a clean, expected shutdown rather than a connection that died.Clean codes: 1000 (normal), 1001 (going away — a page or window navigating away or closing), 1005 (no status code was present in the close frame, which a plain
close()with no arguments produces), and INTENTIONAL_CLOSE_CODE, this codebase's own marker for a close we initiated on purpose. What all four have in common is that a closing handshake completed. The code that matters is 1006: no close frame was ever received, the fingerprint of a connection that died rather than being closed — the shape a suspend produces.Shared so the client and server close handlers cannot independently drift on which codes count as clean. isCleanCloseEvent is the predicate to use where the event itself is in hand.