Merge pull request 'fix(lotus): a homeserver stall shorter than the delayed-leave window no longer ends the call (#46)' (#54) from lotus-stall-retry into lotus
CI / Build embedded bundle (push) Canceled after 0s
CI / Publish to Gitea npm registry (push) Canceled after 0s

This commit was merged in pull request #54.
This commit is contained in:
2026-10-18 04:52:15 -04:00
@@ -868,16 +868,19 @@ export function enterRTCSession(
}; };
} }
// Calculates `maximumNetworkErrorRetryCount`. The connection is failed if EITHER: // Calculates `maximumNetworkErrorRetryCount`: enough retries to outlast the
// - The /sync loop is unresponsive for > `gracePeriod` ms, or // server's delayed-leave window (see [lotus #46] below).
// - A delayed leave event is emitted (after `leaveDelay` ms period).
// Note: Use leaveDelay >> gracePeriod for delegated leave events.
const gracePeriod = Config.get().sync_disconnect_grace_period_ms; const gracePeriod = Config.get().sync_disconnect_grace_period_ms;
const leaveDelay = matrixRtcSessionConfig?.delayed_leave_event_delay_ms; const leaveDelay = matrixRtcSessionConfig?.delayed_leave_event_delay_ms;
const retryInterval = matrixRtcSessionConfig?.network_error_retry_ms; const retryInterval = matrixRtcSessionConfig?.network_error_retry_ms;
// Math.min is used to account for the respective worst case: /sync not available or leave event emitted. // [lotus #46] Keep retrying for as long as the homeserver itself would keep
const maxWaitTime = Math.min(gracePeriod, leaveDelay); // our membership: until its delayed leave fires (`leaveDelay`). Capping at
// the 10 s sync grace period made a ~20–35 s homeserver stall end everyone's
// call ("Connection lost") even with a 60 s server-side leave delay. The
// embedded call has no /sync loop of its own, so the grace period doesn't
// describe anything it can observe.
const maxWaitTime = Math.max(gracePeriod, leaveDelay);
const maximumNetworkErrorRetryCount = const maximumNetworkErrorRetryCount =
Math.ceil(maxWaitTime / retryInterval) + 1; Math.ceil(maxWaitTime / retryInterval) + 1;