-
Notifications
You must be signed in to change notification settings - Fork 26
Fix missing join_ref in PushMessage for Phoenix V2 protocol #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When pushing messages to a Phoenix channel, the V2 JSON serializer expects a join_ref to be included in the message array: [join_ref, ref, topic, event, payload] Without the join_ref, the server cannot properly route the message to the correct channel process, causing client->server messages to be silently dropped while server->client messages work fine. The fix adds join_ref from state.joins[topic], matching the pattern already used in the LeaveTopic handler.
|
It looks like #82 didn't touch this block so I'm not sure it's related. Do you have a reproduction case for the dropped messages? Ideally we can add a test case for this bug |
|
Maybe I am using the library incorrectly but here is a reproduction: https://github.com/evan-hines-js/slipstream_repro main branch uses my fork, no_fork branch uses the official release Run the docker compose for the postgres db and then run the server. On the main branch I see On the no_fork branch, all the messages are lost: |
|
With this reproduction repo, I went back through the Slipstream versions and none of them seem to work. Which is highly unusual because my projects just randomly stopped working without this fork even when I went back 10-20 commits (multiple days) in my own repo. Edit: Found it. Added a new branch to the repro repo no_fork_1.8.2. The issue only occurs with Phoenix 1.8.3 which, according to the changelog has a bug fix that affected how stale join_refs are handled. Now they are dropped. https://hexdocs.pm/phoenix/changelog.html So I'm not sure if this change is needed as-is or something that needs to be investigated further. For now I'll pin Phoenix or use my fork. |
|
Ah ok, that makes sense that it was a change in Phoenix instead. If I |
The join_ref is currently nil when receiving messages in a client -> server flow. Without the join_ref, the server cannot properly route the message to the correct channel process, causing client->server messages to be silently dropped while server->client messages work fine.
The fix adds join_ref from state.joins[topic], matching the pattern already used in the LeaveTopic handler.
This randomly started happening in several of my projects in the last week without explicit code changes so seems to have been added in 1.2.1 during the struct refactor although I have not investigated deeply.