Skip to content

VAPI-4167 fix: final in-call stats lost the call's inbound counters - #28

Merged
smoghe-bw merged 1 commit into
mainfrom
VAPI-4167_fix-final-in-call-stats
Oct 14, 2026
Merged

smoghe-bw merged 1 commit into
mainfrom
VAPI-4167_fix-final-in-call-stats

Conversation

@smoghe-bw

@smoghe-bw smoghe-bw commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Jira: VAPI-4167

Summary

  • The gateway ends a call with a subscribe SDP re-offer that removes the call's track. onremovetrack fires during setRemoteDescription, so the "Final in-call stats (call ended)" read ran after the inbound-rtp stats were gone and always logged zero inbound counters, jitter: 0, codec: "unknown".
  • handleSubscribeSdpOffer now reads a snapshot before setRemoteDescription while the in-call trace is running (inside the subscribe mutex), and keeps it only if complete.
  • When the last call stream ends, that snapshot is logged as the final one. Without one, the fresh read is used as before.
  • The stash is cleared on every trace stop and before each pre-offer read, so it never carries into a later call. Disconnect, signaling disconnected, connect and reconnect keep the fresh read, which still runs before the peer connections close.

Test plan

  • npm test (175 passed)
  • Re-offer that ends the call logs the pre-offer inbound values, and getStats runs before setRemoteDescription
  • No read or stash on subscribe offers when no in-call trace runs
  • A stash from one call is not used by a later call; disconnect still does a fresh final read
  • Incomplete pre-offer read falls back to the fresh read

🤖 Generated with Claude Code

The gateway ends a call with a subscribe re-offer that removes its track, so
the final read ran after the inbound-rtp stats were gone and logged zeros.
Read the snapshot before applying a subscribe re-offer during a call and log
it as the final one when the call's stream ends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@smoghe-bw
smoghe-bw requested review from a team as code owners October 14, 2026 20:01
@bwappsec

bwappsec commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@smoghe-bw
smoghe-bw merged commit 6abfb52 into main Oct 14, 2026
5 checks passed
@smoghe-bw
smoghe-bw deleted the VAPI-4167_fix-final-in-call-stats branch October 14, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants