Skip to content

Commit 215c3ba

Browse files
Fix the RPC comment and clamp the timeout if the provided value is less than 8s (#1694)
Co-authored-by: lukasIO <mail@lukasseiler.de>
1 parent a5a0333 commit 215c3ba

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.changeset/kind-cooks-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
fix the RPC comment and clam the timeout if the provided value is less than 8s

src/room/participant/LocalParticipant.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,7 @@ export default class LocalParticipant extends Participant {
17741774
responseTimeout = 15000,
17751775
}: PerformRpcParams): Promise<string> {
17761776
const maxRoundTripLatency = 7000;
1777+
const minEffectiveTimeout = maxRoundTripLatency + 1000;
17771778

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

1793+
const effectiveTimeout = Math.max(responseTimeout, minEffectiveTimeout);
17921794
const id = crypto.randomUUID();
1793-
await this.publishRpcRequest(
1794-
destinationIdentity,
1795-
id,
1796-
method,
1797-
payload,
1798-
responseTimeout - maxRoundTripLatency,
1799-
);
1795+
await this.publishRpcRequest(destinationIdentity, id, method, payload, effectiveTimeout);
18001796

18011797
const ackTimeoutId = setTimeout(() => {
18021798
this.pendingAcks.delete(id);

src/room/rpc.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ export interface PerformRpcParams {
1111
method: string;
1212
/** The method payload */
1313
payload: string;
14-
/** Timeout for receiving a response after initial connection (milliseconds). Default: 10000 */
14+
/**
15+
* Timeout for receiving a response after the initial connection (milliseconds).
16+
* If a value less than 8000ms is provided, it will be automatically clamped to 8000ms
17+
* to ensure sufficient time for round-trip latency buffering.
18+
* Default: 15000ms.
19+
*/
1520
responseTimeout?: number;
1621
}
1722

0 commit comments

Comments
 (0)