@stream-io/video-client 1.40.1 → 1.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.browser.es.js +26 -4
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +26 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +26 -4
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamSfuClient.d.ts +6 -1
- package/package.json +1 -1
- package/src/Call.ts +5 -2
- package/src/StreamSfuClient.ts +29 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatcher, IceTrickleBuffer } from './rtc';
|
|
2
|
-
import { JoinRequest, JoinResponse } from './gen/video/sfu/event/events';
|
|
2
|
+
import { Error as SfuErrorEvent, JoinRequest, JoinResponse } from './gen/video/sfu/event/events';
|
|
3
3
|
import { ICERestartRequest, SendAnswerRequest, SendStatsRequest, SetPublisherRequest, TrackMuteState, TrackSubscriptionDetails } from './gen/video/sfu/signal_rpc/signal';
|
|
4
4
|
import { ICETrickle } from './gen/video/sfu/models/models';
|
|
5
5
|
import { StreamClient } from './coordinator/connection/client';
|
|
@@ -170,3 +170,8 @@ export declare class StreamSfuClient {
|
|
|
170
170
|
private keepAlive;
|
|
171
171
|
private scheduleConnectionCheck;
|
|
172
172
|
}
|
|
173
|
+
export declare class SfuJoinError extends Error {
|
|
174
|
+
errorEvent: SfuErrorEvent;
|
|
175
|
+
unrecoverable: boolean;
|
|
176
|
+
constructor(event: SfuErrorEvent);
|
|
177
|
+
}
|
package/package.json
CHANGED
package/src/Call.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StreamSfuClient } from './StreamSfuClient';
|
|
1
|
+
import { SfuJoinError, StreamSfuClient } from './StreamSfuClient';
|
|
2
2
|
import {
|
|
3
3
|
BasePeerConnectionOpts,
|
|
4
4
|
Dispatcher,
|
|
@@ -908,7 +908,10 @@ export class Call {
|
|
|
908
908
|
break;
|
|
909
909
|
} catch (err) {
|
|
910
910
|
this.logger.warn(`Failed to join call (${attempt})`, this.cid);
|
|
911
|
-
if (
|
|
911
|
+
if (
|
|
912
|
+
(err instanceof ErrorFromResponse && err.unrecoverable) ||
|
|
913
|
+
(err instanceof SfuJoinError && err.unrecoverable)
|
|
914
|
+
) {
|
|
912
915
|
// if the error is unrecoverable, we should not retry as that signals
|
|
913
916
|
// that connectivity is good, but the coordinator doesn't allow the user
|
|
914
917
|
// to join the call due to some reason (e.g., ended call, expired token...)
|
package/src/StreamSfuClient.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
SfuEventKinds,
|
|
15
15
|
} from './rtc';
|
|
16
16
|
import {
|
|
17
|
+
Error as SfuErrorEvent,
|
|
17
18
|
JoinRequest,
|
|
18
19
|
JoinResponse,
|
|
19
20
|
SfuRequest,
|
|
@@ -26,7 +27,10 @@ import {
|
|
|
26
27
|
TrackMuteState,
|
|
27
28
|
TrackSubscriptionDetails,
|
|
28
29
|
} from './gen/video/sfu/signal_rpc/signal';
|
|
29
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
ICETrickle,
|
|
32
|
+
WebsocketReconnectStrategy,
|
|
33
|
+
} from './gen/video/sfu/models/models';
|
|
30
34
|
import { StreamClient } from './coordinator/connection/client';
|
|
31
35
|
import { generateUUIDv4 } from './coordinator/connection/utils';
|
|
32
36
|
import { Credentials } from './gen/coordinator';
|
|
@@ -537,15 +541,27 @@ export class StreamSfuClient {
|
|
|
537
541
|
const current = this.joinResponseTask;
|
|
538
542
|
|
|
539
543
|
let timeoutId: NodeJS.Timeout | undefined = undefined;
|
|
544
|
+
const unsubscribeJoinErrorEvents = this.dispatcher.on('error', (event) => {
|
|
545
|
+
const { error, reconnectStrategy } = event;
|
|
546
|
+
if (!error) return;
|
|
547
|
+
if (reconnectStrategy === WebsocketReconnectStrategy.DISCONNECT) {
|
|
548
|
+
clearTimeout(timeoutId);
|
|
549
|
+
unsubscribe?.();
|
|
550
|
+
unsubscribeJoinErrorEvents();
|
|
551
|
+
current.reject(new SfuJoinError(event));
|
|
552
|
+
}
|
|
553
|
+
});
|
|
540
554
|
const unsubscribe = this.dispatcher.on('joinResponse', (joinResponse) => {
|
|
541
555
|
clearTimeout(timeoutId);
|
|
542
556
|
unsubscribe();
|
|
557
|
+
unsubscribeJoinErrorEvents();
|
|
543
558
|
this.keepAlive();
|
|
544
559
|
current.resolve(joinResponse);
|
|
545
560
|
});
|
|
546
561
|
|
|
547
562
|
timeoutId = setTimeout(() => {
|
|
548
563
|
unsubscribe();
|
|
564
|
+
unsubscribeJoinErrorEvents();
|
|
549
565
|
const message = `Waiting for "joinResponse" has timed out after ${this.joinResponseTimeout}ms`;
|
|
550
566
|
this.tracer?.trace('joinRequestTimeout', message);
|
|
551
567
|
current.reject(new Error(message));
|
|
@@ -631,3 +647,15 @@ export class StreamSfuClient {
|
|
|
631
647
|
}, this.unhealthyTimeoutInMs);
|
|
632
648
|
};
|
|
633
649
|
}
|
|
650
|
+
|
|
651
|
+
export class SfuJoinError extends Error {
|
|
652
|
+
errorEvent: SfuErrorEvent;
|
|
653
|
+
unrecoverable: boolean;
|
|
654
|
+
|
|
655
|
+
constructor(event: SfuErrorEvent) {
|
|
656
|
+
super(event.error?.message || 'Join Error');
|
|
657
|
+
this.errorEvent = event;
|
|
658
|
+
this.unrecoverable =
|
|
659
|
+
event.reconnectStrategy === WebsocketReconnectStrategy.DISCONNECT;
|
|
660
|
+
}
|
|
661
|
+
}
|