Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors thrown in signal client callbacks #1063

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

HermanBilous
Copy link
Contributor

@HermanBilous HermanBilous commented Mar 5, 2024

No description provided.

Copy link

changeset-bot bot commented Mar 5, 2024

🦋 Changeset detected

Latest commit: 3e5e096

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catching those is a good call, but they should trigger an action to try to fix things. The right call would likely be a full reconnect with

this.fullReconnectOnNext = true;
this.handleDisconnect(errorDescription);

log.error(`failed to setPublisherAnswer: ${errorMessage}`, {
...this.logContext,
RTCSdpType: sd.type,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably trigger a reconnect

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into it again, and it looks like I'm not going to catch an InvalidStateError here at all, and instead I will get a NegotiationError. Should I look for it instead? This looks like an oddly specific error to handle and to try reconnect on.

@@ -456,16 +465,30 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
return;
}
this.log.trace('got ICE candidate from peer', { ...this.logContext, candidate, target });
this.pcManager.addIceCandidate(candidate, target);
this.pcManager.addIceCandidate(candidate, target).catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of an InvalidStateError this should probably also trigger a reconnect

try {
const answer = await this.pcManager.createSubscriberAnswerFromOffer(sd);
await this.client.sendAnswer(answer);
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@HermanBilous HermanBilous changed the title Catch errors when peer connection signaling state is closed Catch errors when signal handlers throw exceptions Mar 5, 2024
@HermanBilous HermanBilous changed the title Catch errors when signal handlers throw exceptions Handle errors thrown in signal client callbacks Mar 5, 2024
@HermanBilous
Copy link
Contributor Author

Added handling of DomExceptions with name = InvalidStateError

@HermanBilous
Copy link
Contributor Author

@lukasIO, could you please take a look? I need a hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants