Closed ruslandoga closed 2 years ago
@dsrees if my understanding of the issue is correct, and supporting V2 serialiser would indeed fix it, would you be open to a PR?
@ruslandoga that would be great. I've never gotten around to supporting the v2 serializer and would appreciate it
Released in 3.x
👋
What happens
We are encountering a race condition where
phx_close
events for channel instances ofphx_leave
djoin_ref
s are closing channel instances of newer (notphx_leave
d)join_ref
s.Example logs:
What's expected to happen
phx_close
needs to take into accountjoin_ref
of the channel before closing itWhy it happens
This happens because
Phoenix.Socket.V1.JSONSerializer
is used right now in SwiftPhoenixClient which doesn't encodejoin_ref
leading toisMember
to only do equality checks on channel topics.How can it be fixed
I can implement a custom serialiser on backend that's a copy of V1 but includes
join_ref
fields, SwiftPhoenixClient seems to already support them, but I'd rather use V2 serialiser instead on backend that is both slightly more efficient and includesjoin_ref
. For that to happen SwiftPhoenixClient needs to addvsn=2.0.0
to the query string in the websocket url and it also needs to be able to decode the new format, still json, but an array instead of a map. For backwards-compatibility it can be opt-in.