diff --git a/packages/realtime_client/lib/src/push.dart b/packages/realtime_client/lib/src/push.dart index d997ab18..6cd8355e 100644 --- a/packages/realtime_client/lib/src/push.dart +++ b/packages/realtime_client/lib/src/push.dart @@ -17,7 +17,6 @@ class Push { Map? _receivedResp; final List _recHooks = []; String? _refEvent; - bool rateLimited = false; /// The channel final RealtimeChannel _channel; @@ -59,7 +58,7 @@ class Push { } startTimeout(); sent = true; - final status = _channel.socket.push( + _channel.socket.push( Message( topic: _channel.topic, event: _event, @@ -68,9 +67,6 @@ class Push { joinRef: _channel.joinRef, ), ); - if (status == 'rate limited') { - rateLimited = true; - } } void updatePayload(Map payload) { diff --git a/packages/realtime_client/lib/src/realtime_channel.dart b/packages/realtime_client/lib/src/realtime_channel.dart index e90c551a..ed2019aa 100644 --- a/packages/realtime_client/lib/src/realtime_channel.dart +++ b/packages/realtime_client/lib/src/realtime_channel.dart @@ -518,10 +518,6 @@ class RealtimeChannel { opts['timeout'] ?? _timeout, ); - if (push.rateLimited) { - completer.complete(ChannelResponse.rateLimited); - } - if (payload['type'] == 'broadcast' && (params['config']?['broadcast']?['ack'] == null || params['config']?['broadcast']?['ack'] == false)) { diff --git a/packages/realtime_client/lib/src/realtime_client.dart b/packages/realtime_client/lib/src/realtime_client.dart index a09fd85c..c3f6cd12 100644 --- a/packages/realtime_client/lib/src/realtime_client.dart +++ b/packages/realtime_client/lib/src/realtime_client.dart @@ -81,8 +81,6 @@ class RealtimeClient { }; int longpollerTimeout = 20000; SocketStates? connState; - int eventsPerSecondLimitMs = 100; - bool inThrottle = false; /// Initializes the Socket /// @@ -122,11 +120,6 @@ class RealtimeClient { if (headers != null) ...headers, }, transport = transport ?? createWebSocketClient { - final eventsPerSecond = params['eventsPerSecond']; - if (eventsPerSecond != null) { - eventsPerSecondLimitMs = (1000 / int.parse(eventsPerSecond)).floor(); - } - final customJWT = this.headers['Authorization']?.split(' ').last; accessToken = customJWT ?? params['apikey']; @@ -288,7 +281,6 @@ class RealtimeClient { /// /// If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established. String? push(Message message) { - final event = message.event; void callback() { encode(message.toJson(), (result) => conn?.sink.add(result)); } @@ -297,18 +289,7 @@ class RealtimeClient { message.payload); if (isConnected) { - if ([ - ChannelEvents.broadcast, - ChannelEvents.presence, - ChannelEvents.postgresChanges - ].contains(event)) { - final isThrottled = _throttle(callback)(); - if (isThrottled) { - return 'rate limited'; - } - } else { - callback(); - } + callback(); } else { sendBuffer.add(callback); } @@ -487,17 +468,4 @@ class RealtimeClient { )); setAuth(accessToken); } - - bool Function() _throttle(Function callback, [int? eventsPerSecondLimit]) { - return () { - if (inThrottle) return true; - callback(); - inThrottle = true; - Timer( - Duration( - milliseconds: eventsPerSecondLimit ?? eventsPerSecondLimitMs), - () => inThrottle = false); - return false; - }; - } } diff --git a/packages/realtime_client/lib/src/types.dart b/packages/realtime_client/lib/src/types.dart index 847d2519..77f2e9de 100644 --- a/packages/realtime_client/lib/src/types.dart +++ b/packages/realtime_client/lib/src/types.dart @@ -101,7 +101,14 @@ class ChannelFilter { } } -enum ChannelResponse { ok, timedOut, rateLimited, error } +enum ChannelResponse { + ok, + timedOut, + @Deprecated( + 'Client side rate limiting has been removed, and this enum value will never be returned.') + rateLimited, + error +} enum RealtimeListenTypes { postgresChanges, broadcast, presence } diff --git a/packages/supabase/lib/src/realtime_client_options.dart b/packages/supabase/lib/src/realtime_client_options.dart index d0e218f9..b9b14c7e 100644 --- a/packages/supabase/lib/src/realtime_client_options.dart +++ b/packages/supabase/lib/src/realtime_client_options.dart @@ -7,6 +7,8 @@ class RealtimeClientOptions { /// How many events the RealtimeClient can push in a second /// /// Defaults to 10 events per second + @Deprecated( + 'Client side rate limit has been removed. This option will be ignored.') final int? eventsPerSecond; /// Level of realtime server logs to to be logged diff --git a/packages/supabase/lib/src/supabase_client.dart b/packages/supabase/lib/src/supabase_client.dart index 62b83b00..7b4b9500 100644 --- a/packages/supabase/lib/src/supabase_client.dart +++ b/packages/supabase/lib/src/supabase_client.dart @@ -255,12 +255,10 @@ class SupabaseClient { RealtimeClient _initRealtimeClient({ required RealtimeClientOptions options, }) { - final eventsPerSecond = options.eventsPerSecond; return RealtimeClient( _realtimeUrl, params: { 'apikey': _supabaseKey, - if (eventsPerSecond != null) 'eventsPerSecond': '$eventsPerSecond' }, headers: headers, logLevel: options.logLevel,