diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 4bf151f9..5d087f72 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -48,6 +48,7 @@ class CallSession extends Emitter { this.taskIdx = 0; this.stackIdx = 0; this.callGone = false; + this.notifiedComplete = false; this.tmpFiles = new Set(); @@ -988,6 +989,12 @@ class CallSession extends Emitter { _notifyCallStatusChange({callStatus, sipStatus, duration}) { if (this.callMoved) return; + /* race condition: we hang up at the same time as the caller */ + if (callStatus === CallStatus.Completed) { + if (this.notifiedComplete) return; + this.notifiedComplete = true; + } + assert((typeof duration === 'number' && callStatus === CallStatus.Completed) || (!duration && callStatus !== CallStatus.Completed), 'duration MUST be supplied when call completed AND ONLY when call completed');