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

fix: improved error handling when connecting to an SFU #1648

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reject signal ready on ws closure
  • Loading branch information
myandrienko committed Jan 20, 2025
commit 3791465427702b174e1de16657b17e9d09d4ad72
10 changes: 7 additions & 3 deletions packages/client/src/StreamSfuClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,19 @@ export class StreamSfuClient {
},
});

this.signalWs.addEventListener('close', this.handleWebSocketClose);

this.signalReady = makeSafePromise(
Promise.race<WebSocket>([
new Promise((resolve) => {
new Promise((resolve, reject) => {
const onOpen = () => {
this.signalWs.removeEventListener('open', onOpen);
resolve(this.signalWs);
};

this.signalWs.addEventListener('close', () => {
reject();
this.handleWebSocketClose();
});

this.signalWs.addEventListener('open', onOpen);
}),

Expand Down