Skip to content

fix: attach callId and map fetch failures - #26

Open
Arshgill01 wants to merge 1 commit into
CALLE-AI:mainfrom
Arshgill01:fix/create-and-wait-call-id
Open

Arshgill01 wants to merge 1 commit into
CALLE-AI:mainfrom
Arshgill01:fix/create-and-wait-call-id

Conversation

@Arshgill01

Copy link
Copy Markdown

What

  1. Wrap the Calls transport fetch so a rejected fetch becomes CalleConnectionError instead of a raw TypeError.
  2. After createAndWait successfully POSTs, attach callId on CalleAPIError, CalleConnectionError, and CalleTimeoutError thrown from the wait-phase GET.
  3. waitForResult timeout already named the id in the message; it now also sets the callId property.

Why

createAndWait kept call.id in a local variable. If the following GET failed (network, 5xx, deadline), the thrown error had no callId field, so the caller could not recover a call that had already been created. A rejected fetch was not mapped to CalleConnectionError, so catch (e instanceof CalleError) missed it.

Related but not fixed: #17 (wait returns on terminal status before structuredResult) and #23 (deadline does not abort GET/sleep). This PR does not change the wait predicate or timeout bounding.

Evidence

Vitest, mocked fetch, no network, no phone call.

Before (published 0.7.0 probe):

[createAndWait: POST ok, GET rejects]  threw TypeError: fetch failed   callId missing
[createAndWait: POST ok, GET 502]      threw CalleAPIError             callId missing
[fetch rejects on POST create]         threw TypeError: fetch failed

After:

pnpm test
 ✓ tests/calls.test.ts (10 tests)

 Test Files  5 passed (5)
      Tests  39 passed (39)

pnpm run typecheck
# exit 0

New cases: rejected fetch on create is CalleConnectionError; POST-ok then GET reject or GET 502 includes callId: "call_123".

Test

pnpm test and pnpm run typecheck as above.

Source

From the CALL-E hackathon feedback lab: https://github.com/Arshgill01/ExactRef/blob/main/docs/feedback/lab/XR-605-create-and-wait-loses-call-id.md

Made with Cursor

createAndWait discarded the created call id when the following GET
failed, and a rejected fetch surfaced as TypeError instead of
CalleConnectionError.

Co-authored-by: Cursor <cursoragent@cursor.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.

calls.waitForResult returns before the result arrives, while goals.waitForResult waits for it

1 participant