Skip to content

Serializer.decode() crashes when Realtime server sends non-array WebSocket message #2107

@whaaaley

Description

@whaaaley

Describe the bug

Serializer.decode() crashes when the Realtime server sends a JSON object over the WebSocket instead of the expected array format. This crashes the entire process with an unhandled TypeError.

Library affected

supabase-js

Reproduction

No response

Steps to reproduce

  1. Subscribe to postgres_changes on a table
  2. Trigger an INSERT via a cron job or external process
  3. The Realtime server occasionally sends a non-array JSON message
  4. Process crashes with the stack trace below

System Info

- @supabase/supabase-js: ^2.56.0
- @supabase/realtime-js: 2.93.3
- Runtime: Deno 2.6.3
- Local Supabase via supabase start

Used Package Manager

npm

Logs

error: Uncaught TypeError: jsonPayload is not iterable
            const [join_ref, ref, topic, event, payload] = jsonPayload;
                                                           ^
    at Serializer.decode (realtime-js/dist/main/lib/serializer.js:104:60)
    at RealtimeClient._onConnMessage (realtime-js/dist/main/RealtimeClient.js:455:14)
    at WebSocket.conn.onmessage (realtime-js/dist/main/RealtimeClient.js:519:47)

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrepro neededIssue is missing a reproduction example.supabase-jsRelated to the supabase-js library.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions