Whether a close event represents an orderly shutdown rather than a connection that died.
wasClean is the authoritative answer — it reports whether a closing handshake completed — so it
wins whenever the event carries it. Both Chromium and the ws library always set it; the
isCleanCloseCode fallback covers a partial or foreign event shape that does not.
Deciding on the code alone would misreport a close frame that carried no status: that arrives as
1005 with wasClean true, which a plain close() produces on every window close and page
reload. Marking those abnormal would bury a genuine socket death under routine noise.
Parameters
ev: unknown
A WebSocket close event, or anything at all — a non-event is reported as not clean
Whether a close event represents an orderly shutdown rather than a connection that died.
wasCleanis the authoritative answer — it reports whether a closing handshake completed — so it wins whenever the event carries it. Both Chromium and thewslibrary always set it; the isCleanCloseCode fallback covers a partial or foreign event shape that does not.Deciding on the code alone would misreport a close frame that carried no status: that arrives as 1005 with
wasCleantrue, which a plainclose()produces on every window close and page reload. Marking those abnormal would bury a genuine socket death under routine noise.