papi-dts
    Preparing search index...

    Function describeWebSocketCloseEvent

    • Describe a WebSocket close event for a log line.

      Chromium and the ws library deliver structurally different close events, and both keep code/reason/wasClean as accessors on the prototype rather than own properties — so JSON.stringify on one yields {}. Read the fields explicitly instead.

      code is 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 an abnormal=true pair. The marker is its own pair rather than a parenthetical inside code= so the whole detail stays a sequence of space-separated key=value pairs.

      Parameters

      • ev: unknown

        A WebSocket close event, or anything at all

      Returns string

      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.