Presence can send both a `Leave` and `Join` event that cancel each other out.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp
- Domain
- backend-api-design
Research direction
Start with the client handling for the presence_diff event and the phx_ref/phx_ref_prev values shown in the report. Reproduce a manual Track Event while already joined, then verify that a matching join and leave are treated as a sync rather than separate Join and Leave events.
Written by the indexing model from the issue text.
Description
I noticed that sending a Track Event manually whilst already joined to the channel causes both a Join and Leave eventto be raised. However, the Leave event is raised after the join making it appear as though I left when I didn't.
29 May 2023 12:08:29 Sending Track Event
29 May 2023 12:08:29 Realtime Client Debug Message: Socket Push [topic: realtime:11111111111111111111111111111111, event: presence, ref: 5d6df879-afa3-4961-8eea-c8f548630ad9]: { "event": "track", "payload": { "LastSeen": "2023-05-29T11:08:29.1576795Z", "Email": "xxx@gmail.com", "Name": "Daz Kuffs", "ComputerName": "RAGE", "UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a", "ConnectID": "00000000-0000-0000-0000-000000000000", "SharedInstances": [ { "InstanceID": "409f44f0-0542-49bc-bec5-47de2b59be48", "InstanceName": "Ruffster", "ComputerName": "RAGE", "RemoteComputerID": "1a796a13-bd00-4a35-835e-648682a2601b", "UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a" } ] }}
29 May 2023 12:08:29 Realtime Client Debug Message: Socket Message Received: {"event":"phx_reply","payload":{"response":{},"status":"ok"},"ref":"5d6df879-afa3-4961-8eea-c8f548630ad9","topic":"realtime:11111111111111111111111111111111"}
29 May 2023 12:08:29 Realtime Client Debug Message: Socket Message Received: {"event":"presence_diff","payload":{"joins":{"145bacf8-fe11-11ed-9abb-6a2047d90b67":{"metas":[{"phx_ref":"F2OYoo6yrtA9v9zm","phx_ref_prev":"F2OYnFmge_Q9v3RI","ComputerName":"RAGE","ConnectID":"00000000-0000-0000-0000-000000000000","Email":"kuffs2205@gmail.com","LastSeen":"2023-05-29T11:08:29.1576795Z","Name":"Daz Kuffs","SharedInstances":[{"ComputerName":"RAGE","InstanceID":"409f44f0-0542-49bc-bec5-47de2b59be48","InstanceName":"Ruffster","RemoteComputerID":"1a796a13-bd00-4a35-835e-648682a2601b","UserID":"7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"}],"UserID":"7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"}]}},"leaves":{"145bacf8-fe11-11ed-9abb-6a2047d90b67":{"metas":[{"phx_ref":"F2OYnFmge_Q9v3RI","ComputerName":"RAGE","ConnectID":"00000000-0000-0000-0000-000000000000","Email":"xxx@gmail.com","LastSeen":"2023-05-29T11:08:02.5031865Z","Name":"Daz Kuffs","SharedInstances":[{"ComputerName":"RAGE","InstanceID":"409f44f0-0542-49bc-bec5-47de2b59be48","InstanceName":"Ruffster","RemoteComputerID":"1a796a13-bd00-4a35-835e-648682a2601b","UserID":"7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"}],"UserID":"7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"}]}}},"ref":null,"topic":"realtime:11111111111111111111111111111111"}
29 May 2023 12:08:29 Presence Sync: Daz Kuffs on RAGE
29 May 2023 12:08:29 Presence Join: Daz Kuffs on RAGE
29 May 2023 12:08:29 Presence Leave: Daz Kuffs on RAGE
I notice that the Json for the Join Event apparently (with my limited knowledge) contains a reference to the Leave event in the : phx_ref_prev field.
Maybe some internal magic needs to check for this and not raise events when they cancel each other out. Personally, I feel that this should only have raised a Sync event and neither a Join or Leave.
Here is the Json for easier viewing.
{
"event": "presence_diff",
"payload":
{
"joins":
{
"145bacf8-fe11-11ed-9abb-6a2047d90b67":
{
"metas":
[
{
"ComputerName": "RAGE",
"ConnectID": "00000000-0000-0000-0000-000000000000",
"Email": "xxx@gmail.com",
"LastSeen": "2023-05-29T11:08:29.1576795Z",
"Name": "Daz Kuffs",
"phx_ref": "F2OYoo6yrtA9v9zm",
"phx_ref_prev": "F2OYnFmge_Q9v3RI", ' MATCH '
"SharedInstances":
[
{
"ComputerName": "RAGE",
"InstanceID": "409f44f0-0542-49bc-bec5-47de2b59be48",
"InstanceName": "Ruffster",
"RemoteComputerID": "1a796a13-bd00-4a35-835e-648682a2601b",
"UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"
}
],
"UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"
}
]
}
},
"leaves":
{
"145bacf8-fe11-11ed-9abb-6a2047d90b67":
{
"metas":
[
{
"ComputerName": "RAGE",
"ConnectID": "00000000-0000-0000-0000-000000000000",
"Email": "xxx@gmail.com",
"LastSeen": "2023-05-29T11:08:02.5031865Z",
"Name": "Daz Kuffs",
"phx_ref": "F2OYnFmge_Q9v3RI", ' MATCH '
"SharedInstances":
[
{
"ComputerName": "RAGE",
"InstanceID": "409f44f0-0542-49bc-bec5-47de2b59be48",
"InstanceName": "Ruffster",
"RemoteComputerID": "1a796a13-bd00-4a35-835e-648682a2601b",
"UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"
}
],
"UserID": "7aaab6a9-fe93-47e9-a3d0-eb717389cf9a"
}
]
}
}
},
"ref": null,
"topic": "realtime:11111111111111111111111111111111"
}
Originally posted by @Kuffs2205 in https://github.com/supabase-community/realtime-csharp/issues/29#issuecomment-1567024728
- Dominant language
- C#
- Stars
- 701
- Forks
- 106
- Avg merge
- 16h 35m
- Merged PRs (30d)
- 45
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/supabase-csharp
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
supabase/supabase-csharp#440 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
supabase/supabase-csharp#437 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
supabase/supabase-csharp#427 ·
-
supabase/supabase-csharp#409 · 1 comment · 1 assignee ·
-
area: realtime bug parity
supabase/supabase-csharp#393 · 1 assignee ·
All issues in supabase/supabase-csharp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100