Conversation
📝 WalkthroughWalkthroughFixes race conditions: Call.join now waits for a non-connecting state with explicit timeout handling; consumeAndAcceptActiveCall ensures coordinator WebSocket is connected before consuming and accepting incoming calls; iOS push plugin buffers events until an EventChannel listener registers. Changes
Sequence Diagram(s)sequenceDiagram
participant SV as StreamVideo
participant WS as CoordinatorWS
participant Call as CallService
participant App as AppHandler
rect rgba(200,220,255,0.5)
SV->>WS: ensure connect()
alt connect success
SV->>WS: consumeActiveCall()
alt consume returns call data
SV->>Call: create/lookup Call object
SV->>Call: accept()
alt accept success
Call-->>SV: accepted
SV->>App: onCallAccepted(call)
else accept failure
Call-->>SV: accept failed
SV->>App: log error / return false
end
else no call or consume failure
WS-->>SV: no call / error
SV->>App: return false
end
else connect failure
WS-->>SV: connect failed
SV->>App: log error / return false
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1185 +/- ##
========================================
- Coverage 6.36% 6.36% -0.01%
========================================
Files 615 615
Lines 43345 43362 +17
========================================
+ Hits 2757 2758 +1
- Misses 40588 40604 +16 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/stream_video/lib/src/call/call.dart`:
- Around line 839-861: The wait for an ongoing connect treats transient join
states as failures; update the predicate used with state.firstWhere in join() so
it treats CallStatusConnecting, CallStatusJoining and CallStatusJoined as
in‑flight (i.e. continue waiting) and only resolves when a terminal state is
reached (e.g. CallStatusConnected or a terminal failure). In practice change the
firstWhere check around state.firstWhere(...) so it excludes Connecting, Joining
and Joined (rather than only Connecting), then keep the existing handling that
treats CallStatusConnected as success and other terminal states as error; this
prevents _performJoinCallRequest/_startSession races and avoids spuriously
returning "ongoing connect failed".
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c8e483eb-2290-4b88-998a-8ac7d0ffcadb
📒 Files selected for processing (5)
packages/stream_video/CHANGELOG.mdpackages/stream_video/lib/src/call/call.dartpackages/stream_video/lib/src/stream_video.dartpackages/stream_video_push_notification/CHANGELOG.mdpackages/stream_video_push_notification/ios/stream_video_push_notification/Sources/stream_video_push_notification/StreamVideoPushNotificationPlugin.swift
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/stream_video/lib/src/call/call.dart (1)
844-849: Wait condition may resolve prematurely on transient reconnection states.The predicate
is! CallStatusConnecting && is! CallStatusJoiningresolves when status transitions toCallStatusReconnectingorCallStatusMigrating. These are transient states (percall_status.dartlines 30-42) that can be set bylifecycleCallConnecting()during reconnection flows. Since neither matches the success condition (Connected || Joined), this returns "ongoing connect failed" even though the reconnection may ultimately succeed.Consider waiting for terminal states instead:
♻️ Suggested approach: wait for terminal states
final currentState = await state.firstWhere( (it) => - it.status is! CallStatusConnecting && - it.status is! CallStatusJoining, + it.status is CallStatusConnected || + it.status is CallStatusDisconnected || + it.status is CallStatusReconnectionFailed, timeLimit: _stateManager.callState.preferences.connectTimeout, ); - if (currentState.status is CallStatusConnected || - currentState.status is CallStatusJoined) { + if (currentState.status is CallStatusConnected) { _logger.v(() => '[join] ongoing connect succeeded'); return const Result.success(none); } else {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/stream_video/lib/src/call/call.dart` around lines 844 - 849, The current wait uses a predicate that treats any non-Connecting/Joining state as done and therefore returns prematurely for transient states like CallStatusReconnecting or CallStatusMigrating (see call_status.dart and lifecycleCallConnecting); update the firstWhere predicate on state so it only completes when the call reaches true terminal outcomes (e.g., CallStatusConnected or CallStatusJoined, and optionally terminal failure/ended statuses your domain defines) instead of negating Connecting/Joining, ensuring Reconnecting and Migrating do not satisfy the condition.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/stream_video/lib/src/call/call.dart`:
- Around line 844-849: The current wait uses a predicate that treats any
non-Connecting/Joining state as done and therefore returns prematurely for
transient states like CallStatusReconnecting or CallStatusMigrating (see
call_status.dart and lifecycleCallConnecting); update the firstWhere predicate
on state so it only completes when the call reaches true terminal outcomes
(e.g., CallStatusConnected or CallStatusJoined, and optionally terminal
failure/ended statuses your domain defines) instead of negating
Connecting/Joining, ensuring Reconnecting and Migrating do not satisfy the
condition.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 72be25b3-7321-48d0-9321-781e05bf424b
📒 Files selected for processing (1)
packages/stream_video/lib/src/call/call.dart
Summary by CodeRabbit