Skip to content

Commit f3909a8

Browse files
authored
Fix livekit retry counter (#9651)
1 parent 879f67f commit f3909a8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

plugins/love-resources/src/utils.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ async function withRetries (fn: () => Promise<void>, retries: number, delay: num
543543
await fn()
544544
return
545545
} catch (error) {
546-
if (attempt >= retries) {
546+
if (attempt >= retries - 1) {
547547
throw error
548548
}
549549
console.error(error)
@@ -554,8 +554,8 @@ async function withRetries (fn: () => Promise<void>, retries: number, delay: num
554554
}
555555

556556
async function connect (name: string, room: Room, _id: string): Promise<void> {
557-
const wsURL = getMetadata(love.metadata.WebSocketURL)
558-
if (wsURL === undefined || getCurrentAccount().role === AccountRole.ReadOnlyGuest) {
557+
const wsURL = getLiveKitEndpoint()
558+
if (getCurrentAccount().role === AccountRole.ReadOnlyGuest) {
559559
return
560560
}
561561

@@ -1098,6 +1098,15 @@ export async function createMeetingSchedule (
10981098
}
10991099
}
11001100

1101+
export function getLiveKitEndpoint (): string {
1102+
const endpoint = getMetadata(love.metadata.WebSocketURL)
1103+
if (endpoint === undefined) {
1104+
throw new Error('Livekit endpoint not found')
1105+
}
1106+
1107+
return endpoint
1108+
}
1109+
11011110
export function getLoveEndpoint (): string {
11021111
const endpoint = getMetadata(love.metadata.ServiceEnpdoint)
11031112
if (endpoint === undefined) {

0 commit comments

Comments
 (0)