Skip to content

Report why a voice interview failed to start - #24

Open
Alimaster30 wants to merge 1 commit into
mainfrom
fix/voice-start-failure-reporting
Open

Report why a voice interview failed to start#24
Alimaster30 wants to merge 1 commit into
mainfrom
fix/voice-start-failure-reporting

Conversation

@Alimaster30

Copy link
Copy Markdown
Owner

Why

Every start failure showed the same message:

The interview could not connect. Check your network and microphone, then try again.

That is wrong for most of the causes. A rejected public key, an origin missing from the Vapi allowlist, a bad assistant id, and an exhausted quota all produce it — and none of them can be fixed by checking your network or retrying. Someone hitting this is sent to restart their router while the actual problem is a config value.

What changed

lib/callFailure.ts classifies the call-start-failed payload — Vapi already reports the failed stage and the underlying error — and returns a message that says whether it is a configuration problem, a quota problem, a microphone problem, or genuinely unknown.

Two ordering bugs were discarding the reason anyway:

  • Vapi emits call-start-failed and then returns null from start(). The if (!call) branch overwrote the specific message the event handler had just set. It now only fills in when nothing has explained the failure.
  • start() returns null without attempting anything when the SDK still considers a call started, which stranded retries on the original error. Any existing session is now stopped first.

The raw payload is also logged, because the stage is the only way to tell a service problem from a connection problem after the fact.

Testing

Six new tests in tests/call-failure.test.mjs cover each classification and the fallback. Full suite 26 pass. tsc, eslint clean.

Not verified against a live failure — this exists to make the next one diagnosable.

"Check your network and microphone" was shown for every start failure,
including ones no retry can fix: a rejected public key, an origin that is
not on the Vapi allowlist, a missing assistant id, and an exhausted
quota. Vapi already reports the stage that failed and the underlying
error, so classify them and say which are configuration problems.

Two ordering bugs meant the specific reason was lost anyway. Vapi emits
"call-start-failed" and then returns null from start(), so the generic
branch overwrote the message the event handler had just set; it now only
fills in when nothing has explained the failure. The payload is also
logged, since the stage is the only way to tell a service problem from a
connection problem after the fact.

start() returns null without attempting anything when the SDK still
considers a call started, which stranded retries on the original error.
Stop any existing session before starting a new one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant