Skip to content

Commit

Permalink
Perform full reconnect on leave during reconnect (#1001)
Browse files Browse the repository at this point in the history
* Perform full reconnect on leave during reconnect

* Create slimy-goats-glow.md
  • Loading branch information
lukasIO committed Jan 20, 2024
1 parent 1c886ef commit dc95472
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-goats-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Perform full reconnect on leave during reconnect
7 changes: 6 additions & 1 deletion src/api/SignalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ export class SignalClient {
shouldProcessMessage = true;
}
} else if (this.isEstablishingConnection && resp.message.case === 'leave') {
reject(new ConnectionError('Received leave request while trying to (re)connect'));
reject(
new ConnectionError(
'Received leave request while trying to (re)connect',
ConnectionErrorReason.LeaveRequest,
),
);
} else if (!opts.reconnect) {
// non-reconnect case, should receive join response first
reject(
Expand Down
3 changes: 3 additions & 0 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,9 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
if (error instanceof ConnectionError && error.reason === ConnectionErrorReason.NotAllowed) {
throw new UnexpectedConnectionState('could not reconnect, token might be expired');
}
if (error instanceof ConnectionError && error.reason === ConnectionErrorReason.LeaveRequest) {
throw error;
}
throw new SignalReconnectError(message);
}
this.emit(EngineEvent.SignalResumed);
Expand Down
1 change: 1 addition & 0 deletions src/room/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const enum ConnectionErrorReason {
ServerUnreachable,
InternalError,
Cancelled,
LeaveRequest,
}

export class ConnectionError extends LivekitError {
Expand Down

0 comments on commit dc95472

Please sign in to comment.