fix: multiple bug fixes

isolated users, db backup, weird disconnect issues for long voice sessions,
This commit is contained in:
2026-04-24 22:19:57 +02:00
parent 44588e8789
commit bc2fa7de22
56 changed files with 1861 additions and 133 deletions

View File

@@ -17,8 +17,10 @@ import {
SIGNALING_RECONNECT_MAX_DELAY_MS,
SIGNALING_CONNECT_TIMEOUT_MS,
STATE_HEARTBEAT_INTERVAL_MS,
SIGNALING_KEEPALIVE_INTERVAL_MS,
SIGNALING_TYPE_IDENTIFY,
SIGNALING_TYPE_JOIN_SERVER,
SIGNALING_TYPE_KEEPALIVE,
SIGNALING_TYPE_VIEW_SERVER
} from '../realtime.constants';
@@ -39,6 +41,7 @@ export class SignalingManager {
private signalingReconnectAttempts = 0;
private signalingReconnectTimer: ReturnType<typeof setTimeout> | null = null;
private stateHeartbeatTimer: ReturnType<typeof setInterval> | null = null;
private lastKeepaliveSentAt = 0;
/** Fires every heartbeat tick - the main service hooks this to broadcast state. */
readonly heartbeatTick$ = new Subject<void>();
@@ -391,7 +394,11 @@ export class SignalingManager {
/** Start the heartbeat interval that drives periodic state broadcasts. */
private startHeartbeat(): void {
this.stopHeartbeat();
this.stateHeartbeatTimer = setInterval(() => this.heartbeatTick$.next(), STATE_HEARTBEAT_INTERVAL_MS);
this.lastKeepaliveSentAt = Date.now();
this.stateHeartbeatTimer = setInterval(() => {
this.heartbeatTick$.next();
this.sendKeepaliveIfDue();
}, STATE_HEARTBEAT_INTERVAL_MS);
}
/** Stop the heartbeat interval. */
@@ -400,6 +407,28 @@ export class SignalingManager {
clearInterval(this.stateHeartbeatTimer);
this.stateHeartbeatTimer = null;
}
this.lastKeepaliveSentAt = 0;
}
private sendKeepaliveIfDue(): void {
const now = Date.now();
if (now - this.lastKeepaliveSentAt < SIGNALING_KEEPALIVE_INTERVAL_MS) {
return;
}
this.lastKeepaliveSentAt = now;
try {
this.sendRawMessage({ type: SIGNALING_TYPE_KEEPALIVE });
} catch (error) {
this.logger.warn('[signaling] Failed to send signaling keepalive', {
error,
readyState: this.getSocketReadyStateLabel(),
url: this.lastSignalingUrl
});
}
}
/** Clean up all resources. */