A WebSocket close event, or anything at all
Space-separated key=value pairs — code, abnormal (only when the connection died),
reason (JSON-quoted, so a reason containing a quote or a bracket cannot forge the surrounding
log line) and wasClean. A field that cannot be read is reported as n/a, so a non-event
yields code=n/a reason=n/a wasClean=n/a rather than throwing.
Describe a WebSocket
closeevent for a log line.Chromium and the
wslibrary deliver structurally different close events, and both keepcode/reason/wasCleanas accessors on the prototype rather than own properties — soJSON.stringifyon one yields{}. Read the fields explicitly instead.codeis the single most diagnostic field: 1006 (no close frame) means the connection died rather than being closed politely. A reader should not need the WebSocket code table memorized to see that, so an event that isCleanCloseEvent rejects also carries anabnormal=truepair. The marker is its own pair rather than a parenthetical insidecode=so the whole detail stays a sequence of space-separatedkey=valuepairs.