Skip to content

Commit 7d6a60a

Browse files
authored
Merge pull request #3110 from element-hq/robin/participant-limits
Show "insufficient capacity" when hitting participant limits
2 parents 22977dc + 45c3c7a commit 7d6a60a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/livekit/useECConnectionState.test.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ import { GroupCallErrorBoundary } from "../room/GroupCallErrorBoundary.tsx";
2222

2323
test.each<[string, ConnectionError]>([
2424
[
25-
"LiveKit",
25+
"LiveKit hits track limit",
2626
new ConnectionError("", ConnectionErrorReason.InternalError, 503),
2727
],
2828
[
29-
"LiveKit Cloud",
29+
"LiveKit hits room participant limit",
30+
new ConnectionError("", ConnectionErrorReason.ServerUnreachable, 200),
31+
],
32+
[
33+
"LiveKit Cloud hits connection limit",
3034
new ConnectionError("", ConnectionErrorReason.NotAllowed, 429),
3135
],
3236
])(

src/livekit/useECConnectionState.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,16 @@ async function connectAndPublish(
144144
websocketTimeout: window.websocketTimeout ?? 45000,
145145
});
146146
} catch (e) {
147-
// LiveKit uses 503 to indicate that the server has hit its track limits
148-
// or equivalently, 429 in LiveKit Cloud
149-
// For reference, the 503 response is generated at: https://github.com/livekit/livekit/blob/fcb05e97c5a31812ecf0ca6f7efa57c485cea9fb/pkg/service/rtcservice.go#L171
150-
151-
if (e instanceof ConnectionError && (e.status === 503 || e.status === 429))
147+
// LiveKit uses 503 to indicate that the server has hit its track limits.
148+
// https://github.com/livekit/livekit/blob/fcb05e97c5a31812ecf0ca6f7efa57c485cea9fb/pkg/service/rtcservice.go#L171
149+
// It also errors with a status code of 200 (yes, really) for room
150+
// participant limits.
151+
// LiveKit Cloud uses 429 for connection limits.
152+
// Either way, all these errors can be explained as "insufficient capacity".
153+
if (
154+
e instanceof ConnectionError &&
155+
(e.status === 503 || e.status === 200 || e.status === 429)
156+
)
152157
throw new InsufficientCapacityError();
153158
throw e;
154159
}

0 commit comments

Comments
 (0)