Commit bc0d779
feat(realtime): add explicit REST API broadcast method (#818)
* fix(realtime): add explicit REST API broadcast method
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>
* refactor: rename postSend to httpSend
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>
* drop MainActor
* simplify try/catch
* reuse BroadcastMessagePayload
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 21425be commit bc0d779
File tree
3 files changed
+365
-16
lines changed- Sources/Realtime
- Tests/RealtimeTests
3 files changed
+365
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| |||
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
251 | 334 | | |
252 | 335 | | |
253 | 336 | | |
| |||
263 | 346 | | |
264 | 347 | | |
265 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
266 | 355 | | |
267 | 356 | | |
268 | 357 | | |
| |||
271 | 360 | | |
272 | 361 | | |
273 | 362 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | 363 | | |
286 | 364 | | |
287 | 365 | | |
| |||
543 | 621 | | |
544 | 622 | | |
545 | 623 | | |
546 | | - | |
| 624 | + | |
547 | 625 | | |
548 | 626 | | |
549 | 627 | | |
| |||
562 | 640 | | |
563 | 641 | | |
564 | 642 | | |
565 | | - | |
| 643 | + | |
566 | 644 | | |
567 | 645 | | |
568 | 646 | | |
| |||
581 | 659 | | |
582 | 660 | | |
583 | 661 | | |
584 | | - | |
| 662 | + | |
585 | 663 | | |
586 | 664 | | |
587 | 665 | | |
| |||
673 | 751 | | |
674 | 752 | | |
675 | 753 | | |
| 754 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
0 commit comments