Skip to content

Conversation

filipecabaco
Copy link
Member

What kind of change does this PR introduce?

rate limit presence events

Copy link

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
realtime-demo Ignored Ignored Preview Aug 21, 2025 4:17pm

@filipecabaco filipecabaco force-pushed the fix/rate-limit-presence-events branch from 786f7ef to e23258e Compare August 11, 2025 23:31
@coveralls
Copy link

coveralls commented Aug 11, 2025

Coverage Status

coverage: 84.17% (-0.2%) from 84.324%
when pulling 4bbe3b9 on fix/rate-limit-presence-events
into 5945389 on main.

@filipecabaco filipecabaco force-pushed the fix/rate-limit-presence-events branch from 73957f4 to fb7cda7 Compare August 12, 2025 11:59
@filipecabaco filipecabaco force-pushed the fix/rate-limit-presence-events branch 7 times, most recently from f1d7589 to a0ece8d Compare August 19, 2025 16:21
@filipecabaco filipecabaco requested a review from edgurgel August 19, 2025 20:51
@@ -706,7 +706,6 @@ defmodule Realtime.Integration.RtChannelTest do

WebsocketClient.send_event(socket, topic, "presence", payload)

assert_receive %Phoenix.Socket.Message{topic: ^topic, event: "phx_reply", payload: %{"status" => "ok"}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why this has changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be here as this could be an error actually as this event would mean it reconnected 👀

@filipecabaco filipecabaco force-pushed the fix/rate-limit-presence-events branch from 4f1ce27 to 49402ce Compare August 20, 2025 17:08
@filipecabaco filipecabaco force-pushed the fix/rate-limit-presence-events branch from 49402ce to f923e1d Compare August 20, 2025 17:09
) do
%{assigns: %{authorization_context: authorization_context}} = socket
defp handle_presence_event("track", payload, db_conn, socket)
when can_write_presence?(socket) and is_nil(socket.assigns.policies.presence.write) do
Copy link
Member

@edgurgel edgurgel Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe here it could be only when is_nil(socket.assigns.policies.presence.write) which means we still need to calculate just for this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did this change as it also simplifies a lot the guard of the function

push(socket, "presence_state", presence_dirty_list(topic))
{:noreply, socket}
@spec sync(Socket.t()) ::
:ok | {:error, :rls_policy_error | :unable_to_set_policies | :rate_limit_exceeded}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this function return rls_policy_error or unable_to_set_policies?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no! copy pasta strikes again

Copy link
Member

@edgurgel edgurgel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments but overall LGTM. Nice one

@filipecabaco filipecabaco merged commit 4ef6dd3 into main Aug 21, 2025
6 of 7 checks passed
@filipecabaco filipecabaco deleted the fix/rate-limit-presence-events branch August 21, 2025 16:39
@kiwicopple
Copy link
Member

🎉 This PR is included in version 2.42.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants