Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kind-cooks-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

fix the RPC comment and clam the timeout if the provided value is less than 8s
10 changes: 3 additions & 7 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@ export default class LocalParticipant extends Participant {
responseTimeout = 15000,
}: PerformRpcParams): Promise<string> {
const maxRoundTripLatency = 7000;
const minEffectiveTimeout = maxRoundTripLatency + 1000;

return new Promise(async (resolve, reject) => {
if (byteLength(payload) > MAX_PAYLOAD_BYTES) {
Expand All @@ -1789,14 +1790,9 @@ export default class LocalParticipant extends Participant {
return;
}

const effectiveTimeout = Math.max(responseTimeout, minEffectiveTimeout);
const id = crypto.randomUUID();
await this.publishRpcRequest(
destinationIdentity,
id,
method,
payload,
responseTimeout - maxRoundTripLatency,
);
await this.publishRpcRequest(destinationIdentity, id, method, payload, effectiveTimeout);

const ackTimeoutId = setTimeout(() => {
this.pendingAcks.delete(id);
Expand Down
7 changes: 6 additions & 1 deletion src/room/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ export interface PerformRpcParams {
method: string;
/** The method payload */
payload: string;
/** Timeout for receiving a response after initial connection (milliseconds). Default: 10000 */
/**
* Timeout for receiving a response after the initial connection (milliseconds).
* If a value less than 8000ms is provided, it will be automatically clamped to 8000ms
* to ensure sufficient time for round-trip latency buffering.
* Default: 15000ms.
*/
responseTimeout?: number;
}

Expand Down
Loading