mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-29 16:54:30 +00:00
fix(voice-call): auto-end call when media stream disconnects
When a Twilio media stream disconnects (e.g., caller hangs up or network drops), the call object was left in an active state indefinitely. This caused "stuck calls" that consumed resources and blocked new calls. Now calls are automatically ended when their media stream closes, matching the expected lifecycle behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
a5c94b8e7b
commit
3eec5e54b1
@@ -181,6 +181,13 @@ export class VoiceCallWebhookServer {
|
||||
},
|
||||
onDisconnect: (callId) => {
|
||||
console.log(`[voice-call] Media stream disconnected: ${callId}`);
|
||||
// Auto-end call when media stream disconnects to prevent stuck calls.
|
||||
// Without this, calls can remain active indefinitely after the stream closes.
|
||||
const disconnectedCall = this.manager.getCallByProviderCallId(callId);
|
||||
if (disconnectedCall) {
|
||||
console.log(`[voice-call] Auto-ending call ${disconnectedCall.callId} on stream disconnect`);
|
||||
void this.manager.endCall(disconnectedCall.callId).catch(() => {});
|
||||
}
|
||||
if (this.provider.name === "twilio") {
|
||||
(this.provider as TwilioProvider).unregisterCallStream(callId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user