diff --git a/packages/realtime-api/src/voice/CallPlayback.ts b/packages/realtime-api/src/voice/CallPlayback.ts index c5493a67ca..a892047090 100644 --- a/packages/realtime-api/src/voice/CallPlayback.ts +++ b/packages/realtime-api/src/voice/CallPlayback.ts @@ -160,6 +160,11 @@ export class CallPlaybackAPI this._once('playback.ended', handler) // @ts-expect-error this._once('playback.failed', handler) + + // Resolve the promise if the recording has already ended + if (ENDED_STATES.includes(this.state as CallingCallPlayEndState)) { + handler() + } }) } } diff --git a/packages/realtime-api/src/voice/CallRecording.ts b/packages/realtime-api/src/voice/CallRecording.ts index 3ee2c4c7ee..957f763725 100644 --- a/packages/realtime-api/src/voice/CallRecording.ts +++ b/packages/realtime-api/src/voice/CallRecording.ts @@ -107,6 +107,11 @@ export class CallRecordingAPI // TODO: review what else to return when `recording.failed` happens. // @ts-expect-error this._once('recording.failed', handler) + + // Resolve the promise if the recording has already ended + if (ENDED_STATES.includes(this.state as CallingCallRecordEndState)) { + handler() + } }) } }