Skip to content

fix(server-sdk): leave SIP dial options unmodified - #770

Open
Abhishek-B-R wants to merge 1 commit into
livekit:mainfrom
Abhishek-B-R:fix/sip-dial-options-mutation
Open

Abhishek-B-R wants to merge 1 commit into
livekit:mainfrom
Abhishek-B-R:fix/sip-dial-options-mutation

Conversation

@Abhishek-B-R

Copy link
Copy Markdown

Description

createSipParticipant (with waitUntilAnswered) and transferSipParticipant fill in the default ring window and the derived request timeout by assigning to the options object the caller passed in:

opts.ringingTimeout ??= DEFAULT_RINGING_TIMEOUT_SECONDS;
opts.timeout = dialRequestTimeout(opts.timeout, opts.ringingTimeout);

Two visible effects:

  • After the call, the caller's object has ringingTimeout: 30 and timeout: 32 on it, which they never set. If that object is shared or reused (for example passed to a later createSipParticipant without waitUntilAnswered), those values go out with the next request too.
  • A frozen options object throws before any request is made:
const DIAL = Object.freeze({ waitUntilAnswered: true });
await sip.createSipParticipant(trunkId, number, room, DIAL);
// TypeError: Cannot add property ringingTimeout, object is not extensible

await sip.transferSipParticipant(room, identity, 'tel:+15105550100', Object.freeze({ playDialtone: true }));
// TypeError: Cannot add property ringingTimeout, object is not extensible

This change computes both values in locals and passes those to the request, the same way acceptWhatsAppCall in ConnectorClient already handles its timeout. The request body and the request timeout are unchanged: still ringingTimeout: "30s" and a 32 second timeout by default, and ringingTimeout + 2 when one is given.

Testing

Added src/SipClient.test.ts, which stubs fetch and AbortSignal.timeout and checks, for both methods, that the options object is untouched, that frozen options work, and that the request still carries the expected ringingTimeout and timeout.

  • Before the change: 4 failed (two expected { ..., ringingTimeout: 30, timeout: 32 }, two TypeError: Cannot add property ..., object is not extensible).
  • After the change: 4 passed.

Also ran in packages/livekit-server-sdk: pnpm test, pnpm test:browser, pnpm test:edge (47 passed each, the API tests skip without the mock server), pnpm lint (no new warnings), prettier --check on the changed files, and pnpm build.

A patch changeset for livekit-server-sdk is included.

createSipParticipant (with waitUntilAnswered) and transferSipParticipant
filled in the default ringing window and the derived request timeout by
assigning to the options object the caller passed, so the caller saw
ringingTimeout and timeout appear on their object after the call, and a
frozen options object threw "Cannot add property ... object is not
extensible". Compute both values in locals instead, as acceptWhatsAppCall
already does.
@changeset-bot

changeset-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 742b5bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-server-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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