Skip to content

Commit

Permalink
fix: restore calling state if SFU connection fails during join (#1652)
Browse files Browse the repository at this point in the history
It's important to reset calling state back to its pre-join state if
joining flow fails. We already do this if join request fails, but we
also need to do it if SFU connection fails.
  • Loading branch information
myandrienko authored Jan 21, 2025
1 parent caafaf2 commit ff7f221
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions packages/client/src/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,25 +849,32 @@ export class Call {
const preferredSubscribeOptions = !isReconnecting
? this.getPreferredSubscribeOptions()
: [];
const { callState, fastReconnectDeadlineSeconds, publishOptions } =
await sfuClient.join({
subscriberSdp,
publisherSdp,
clientDetails,
fastReconnect: performingFastReconnect,
reconnectDetails,
preferredPublishOptions,
preferredSubscribeOptions,
});

this.currentPublishOptions = publishOptions;
this.fastReconnectDeadlineSeconds = fastReconnectDeadlineSeconds;
if (callState) {
this.state.updateFromSfuCallState(
callState,
sfuClient.sessionId,
reconnectDetails,
);
try {
const { callState, fastReconnectDeadlineSeconds, publishOptions } =
await sfuClient.join({
subscriberSdp,
publisherSdp,
clientDetails,
fastReconnect: performingFastReconnect,
reconnectDetails,
preferredPublishOptions,
preferredSubscribeOptions,
});

this.currentPublishOptions = publishOptions;
this.fastReconnectDeadlineSeconds = fastReconnectDeadlineSeconds;
if (callState) {
this.state.updateFromSfuCallState(
callState,
sfuClient.sessionId,
reconnectDetails,
);
}
} catch (error) {
// restore the previous call state if the join-flow fails
this.state.setCallingState(callingState);
throw error;
}
}

Expand Down

0 comments on commit ff7f221

Please sign in to comment.