• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-swift / 20075272511 / 1
80%
main: 80%

Build:
DEFAULT BRANCH: main
Ran 09 Dec 2025 07:50PM UTC
Files 86
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

09 Dec 2025 07:04PM UTC coverage: 80.447% (-0.1%) from 80.542%
20075272511.1

push

github

web-flow
fix(realtime): resolve race conditions and connection bugs (#866)

* fix(realtime): resolve critical race conditions and connection bugs

This commit addresses multiple critical bugs in the Realtime implementation
that caused connection instability, resource leaks, and race conditions.

**Critical Race Conditions Fixed:**

1. **Connection Race Condition**
   - Added atomic check for connection state to prevent multiple simultaneous
     WebSocket connections
   - Now validates both status and connectionTask existence before creating
     new connections

2. **Heartbeat Timeout Logic**
   - Fixed inverted logic that caused false timeout detections
   - Now correctly identifies when previous heartbeat wasn't acknowledged
   - Clears pending heartbeat ref before reconnecting

3. **Channel Removal**
   - Fixed missing channel removal from state (critical bug!)
   - Made isEmpty check atomic with removal to prevent race conditions

**Resource Leak Fixes:**

4. **Reconnect Task Management**
   - Added reconnectTask tracking to prevent zombie reconnection loops
   - Cancels previous reconnect before starting new one

5. **Complete State Cleanup**
   - disconnect() now clears pendingHeartbeatRef to prevent stale state
   - Clears sendBuffer to prevent stale messages on reconnect
   - Enhanced deinit cleanup for all tasks and connections

6. **Task Lifecycle**
   - Removed weak self from long-running tasks (messageTask, heartbeatTask)
   - Tasks now use strong references and rely on explicit cancellation
   - Ensures proper WebSocket lifecycle management

**Edge Case Fixes:**

7. **Channel Subscription Verification**
   - Re-checks connection status after socket.connect() await
   - Prevents subscription attempts on failed connections

8. **Atomic Status Updates**
   - onConnected() now sets status AFTER listeners are started
   - Prevents race where error handlers trigger before setup completes

9. **Safe Connection Access**
   - Captures conn reference insid... (continued)

6328 of 7866 relevant lines covered (80.45%)

27.67 hits per line

Source Files on job 20075272511.1
  • Tree
  • List 86
  • Changed 3
  • Source Changed 3
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 20075272511
  • 1266707c on github
  • Prev Job for on main (#19564017052.1)
  • Next Job for on main (#20077597503.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc