Skip to content

Client side failed with reason: {"reason":"unmatched topic"} errors (WebSocket) #4075

@rhcarvalho

Description

@rhcarvalho

Environment

  • Elixir version (elixir -v):
Erlang/OTP 28 [erts-16.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.19.3 (compiled with Erlang/OTP 28)
  • Phoenix version (mix deps) & Phoenix LiveView version (mix deps):
mix deps | grep -E 'phoenix([^_]|_live_view)'
* phoenix 1.8.2 (Hex package) (mix)
  locked at 1.8.2 (phoenix) 19ea65b4
* phoenix_live_view 1.1.18 (Hex package) (mix)
  locked at 1.1.18 (phoenix_live_view) f189b759
  • Operating system: Linux / N/A
  • Browsers you attempted to reproduce this bug on (the more the merrier):
Chrome Mobile 142.0.0
Samsung Internet 29.0
Edge 143.0.0
Chrome Mobile WebView 142.0.7444
Chrome 142.0.0
  • Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: N/A

Actual behavior

tl;dr: I'm seeing failed with reason: {"reason":"unmatched topic"} JavaScript errors and trying to determine what causes them, what's the perceived user experience when they happen and whether they can be ignored.

This is related to https://elixirforum.com/t/handling-channels-liveview-longpoll-fallback-unmatched-topic/72378 and phoenixframework/phoenix#6538 (which landed in Phoenix 1.8.2 and attempted to fix the issue I was investigating and related in the Elixir Forum).

Originally I associated the bulk of our failed with reason: {"reason":"unmatched topic"} JavaScript errors to clients connected via LongPoll.

I've since been tracking the current transport explicitly and reporting it along with client-side errors. This is done by reading window.liveSocket.socket.transport.name and tagging the error event before it is sent out.

I've collected numerous errors events from different browsers in the last few weeks, desktop and mobile, all of which are tagged with the WebSocket transport.

I don't have a fully readable stacktrace to share, but working through the data that I have I see pointers to:

  • Object.callback (maybe refers to ViewHook.callback? Or one of the Push.recHooks values as in Push.matchReceive below)
  • .matchReceive (~ Push.matchReceive in Phoenix)
  • .trigger (maybe Channel.trigger in Phoenix)
  • Object.decode
  • .onConnMessage
  • conn.onmessage

So while I observe the problem in LiveView, it is quite possible the issue/fix lies in Phoenix. Perhaps we need a similar error handling that was added for the LongPoll in the WebSocket transport as well?

Expected behavior

Either no such client side errors or a better understanding why they happen and their consequence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions