Skip to content

fix: honor stop() called while start() is still connecting - #182

Open
RaphaelFakhri wants to merge 1 commit into
VapiAI:mainfrom
RaphaelFakhri:fix/stop-while-connecting
Open

RaphaelFakhri wants to merge 1 commit into
VapiAI:mainfrom
RaphaelFakhri:fix/stop-while-connecting

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

stop() did nothing when it ran before the Daily call object existed. start() kept going, joined the call, and emitted call-start after the caller had already ended the session.

This change adds a start generation counter. stop() increments it, and start() checks it after each await that stop() can overtake:

  • After the web call is created.
  • After the mobile permission wait.
  • After join() resolves or rejects.

A cancelled start() returns null without joining, without emitting call-start-failed or call-start-success, and without touching a call object that a newer start() created.

Fixes #26

Testing

Added __tests__/stopWhileConnecting.test.ts with five cases: stop during web call creation, no failure event for a cancelled start, stop then a new start with the first still pending, stop during join(), and stop during the mobile permission wait.

  • Without the change to vapi.ts: 5 failed, 0 passed.
  • With the change: 5 passed. Full suite: 66 passed, 3 suites.
npx jest

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.

Vapi.stop() doesn't work when the call is still connecting

1 participant