Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Oct 9, 2025

Summary

This PR adds a new httpSend method to the RealtimeChannel class that explicitly uses the REST API endpoint for sending broadcast messages, regardless of WebSocket connection state.

Changes

  • ✨ Added httpSend method with proper error handling and timeout support
  • ⚠️ Added deprecation warning to send method when falling back to REST
  • ✅ Comprehensive test coverage for the new method

Motivation

Currently, the send method automatically falls back to using the REST API when the WebSocket connection is not available. However, this behavior is implicit and users may not be aware they are using REST instead of WebSocket.

This change provides an explicit method for REST delivery, giving users more control over their message delivery mechanism and preparing for future deprecation of the implicit fallback behavior.

Test Plan

  • All existing tests pass
  • New tests for httpSend method covering:
    • Successful 202 responses
    • Authorization header handling (with and without access token)
    • Private channel support
    • Error handling for non-202 status codes
    • Timeout handling
    • Correct payload formatting

Related

Ported from: supabase/supabase-js#1751

🤖 Generated with Claude Code

Added new `httpSend` method to RealtimeChannel class that explicitly uses the REST API endpoint for sending broadcast messages, regardless of WebSocket connection state.

Changes:
- Added `httpSend` method with proper error handling and timeout support
- Added deprecation warning to `send` method when falling back to REST
- Comprehensive test coverage for the new method

This addresses the issue where users may unknowingly use REST API fallback when WebSocket is not connected. The new method provides explicit control over message delivery mechanism.

Ported from: supabase/supabase-js#1751

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 18383152561

Details

  • 26 of 27 (96.3%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 80.988%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/realtime_client/lib/src/realtime_channel.dart 26 27 96.3%
Totals Coverage Status
Change from base Build 18341715674: 0.1%
Covered Lines: 3263
Relevant Lines: 4029

💛 - Coveralls

if (e is TimeoutException) {
rethrow;
}
throw Exception(e.toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Im unsure what the reason for this catch block is. I would just remove it as it either just rethrows the timeout or stringifies the exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants