Ensure transport manager is reset before attempting legacy fallback path (#1893)
Co-authored-by: cnderrauber <zengjiestc@gmail.com>
This commit is contained in:
5
.changeset/rotten-points-collect.md
Normal file
5
.changeset/rotten-points-collect.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"livekit-client": patch
|
||||
---
|
||||
|
||||
Ensure transport manager is reset before attempting legacy fallback path
|
||||
@@ -310,7 +310,7 @@
|
||||
class="btn btn-outline-secondary btn-sm"
|
||||
type="button"
|
||||
onclick="appActions.cancelChatReceive()"
|
||||
style="display: none;"
|
||||
style="display: none"
|
||||
>
|
||||
Cancel current receive
|
||||
</button>
|
||||
|
||||
@@ -220,6 +220,8 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
||||
|
||||
private shouldFailNext: boolean = false;
|
||||
|
||||
private shouldFailOnV1Path: boolean = false;
|
||||
|
||||
private regionUrlProvider?: RegionUrlProvider;
|
||||
|
||||
private log = log;
|
||||
@@ -321,9 +323,16 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
||||
offerProto = toProtoSessionDescription(offer.offer, offer.offerId);
|
||||
}
|
||||
}
|
||||
|
||||
if (abortSignal?.aborted) {
|
||||
throw ConnectionError.cancelled('Connection aborted');
|
||||
}
|
||||
|
||||
if (!useV0Path && this.shouldFailOnV1Path) {
|
||||
this.shouldFailOnV1Path = false;
|
||||
throw ConnectionError.serviceNotFound('Simulated v1 path failure', 'v0-rtc');
|
||||
}
|
||||
log.warn('joining signal with ', url);
|
||||
const joinResponse = await this.client.join(
|
||||
url,
|
||||
token,
|
||||
@@ -383,6 +392,10 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
||||
}
|
||||
} else if (e.reason === ConnectionErrorReason.ServiceNotFound) {
|
||||
this.log.warn(`Initial connection failed: ${e.message} – Retrying`);
|
||||
if (this.pcManager) {
|
||||
this.pcManager.onStateChange = undefined;
|
||||
await this.cleanupPeerConnections();
|
||||
}
|
||||
return this.join(url, token, opts, abortSignal, true);
|
||||
}
|
||||
}
|
||||
@@ -1860,6 +1873,12 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
||||
this.shouldFailNext = true;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
failNextV1Path() {
|
||||
// debugging method to fail the next connection attempt for /rtc/v1 to trigger the fallback version
|
||||
this.shouldFailOnV1Path = true;
|
||||
}
|
||||
|
||||
private dataChannelsInfo(): DataChannelInfo[] {
|
||||
const infos: DataChannelInfo[] = [];
|
||||
const getInfo = (dc: RTCDataChannel | undefined, target: SignalTarget) => {
|
||||
|
||||
@@ -1137,6 +1137,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
||||
// @ts-expect-error function is private
|
||||
await this.engine.client.handleOnClose('simulate disconnect');
|
||||
break;
|
||||
case 'fail-on-v1-path':
|
||||
this.engine.failNextV1Path();
|
||||
break;
|
||||
case 'speaker':
|
||||
req = new SimulateScenario({
|
||||
scenario: {
|
||||
|
||||
@@ -92,7 +92,8 @@ export type SimulationScenario =
|
||||
| 'disconnect-signal-on-resume'
|
||||
| 'disconnect-signal-on-resume-no-messages'
|
||||
// instructs the server to send a full reconnect reconnect action to the client
|
||||
| 'leave-full-reconnect';
|
||||
| 'leave-full-reconnect'
|
||||
| 'fail-on-v1-path';
|
||||
|
||||
export type LoggerOptions = {
|
||||
loggerName?: string;
|
||||
|
||||
Reference in New Issue
Block a user