Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Oct 8, 2025

🔍 Description

This PR ports the feature from supabase-js#1749 which adds an explicit REST API method for sending broadcast messages.

What changed?

  • Added new httpSend() method to RealtimeChannelV2 for explicit REST delivery
  • Added deprecation warning to broadcast() when falling back to REST
  • Comprehensive test coverage for the new method

Why was this change needed?

The current broadcast() method automatically falls back to REST API when the WebSocket is not connected, which can be confusing for users who may not realize they're using REST instead of WebSocket. This change:

  1. Makes REST delivery explicit via the new httpSend() method
  2. Warns users when broadcast() falls back to REST
  3. Prepares for future deprecation of automatic REST fallback

🔄 Changes

  • New Method: httpSend(event:message:timeout:) - Explicitly uses REST API regardless of WebSocket state
  • Deprecation Warning: broadcast() now logs a warning when falling back to REST
  • Error Handling: Proper validation for access tokens, status codes, and error messages
  • Timeout Support: Optional timeout parameter for REST requests

✅ Testing

Added comprehensive tests covering:

  • Access token validation
  • Successful 202 responses
  • Error handling for non-202 status codes
  • Custom timeout handling
  • Default timeout behavior
  • Error message parsing

All tests pass successfully.

📋 Checklist

  • Ported feature from supabase-js
  • Followed existing code patterns and conventions
  • Added comprehensive tests
  • All tests pass
  • Commit follows conventional commit format

📚 References


🤖 Generated with Claude Code

grdsdev and others added 2 commits October 8, 2025 16:05
This commit ports the feature from supabase-js PR #1749 which adds
an explicit `postSend()` method for sending broadcast messages via
REST API, addressing the issue where users may unknowingly use REST
fallback when WebSocket is not connected.

Changes:
- Add `postSend()` method to RealtimeChannelV2 for explicit REST delivery
- Add deprecation warning to `broadcast()` when falling back to REST
- Add comprehensive test coverage for the new method
- Support custom timeout parameter for REST requests
- Include proper error handling and status code validation

The `postSend()` method always uses the REST API endpoint regardless
of WebSocket connection state, making it clear to developers when
they are using REST vs WebSocket delivery.

Ref: supabase/supabase-js#1749

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

Co-Authored-By: Claude <noreply@anthropic.com>
Rename the explicit REST API broadcast method from postSend to
httpSend to better align with naming conventions.

Changes:
- Rename postSend() to httpSend() in RealtimeChannelV2
- Update all test names from testPostSend to testHttpSend
- Update deprecation warning to reference httpSend()
- Update error messages to reference httpSend()

All tests continue to pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@coveralls
Copy link

coveralls commented Oct 8, 2025

Pull Request Test Coverage Report for Build 18382895627

Details

  • 71 of 79 (89.87%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 77.462%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Sources/Realtime/RealtimeChannelV2.swift 71 79 89.87%
Totals Coverage Status
Change from base Build 18320538177: 0.2%
Covered Lines: 5946
Relevant Lines: 7676

💛 - Coveralls

@grdsdev grdsdev requested review from filipecabaco and a team October 9, 2025 16:46
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.

2 participants