@stream-io/video-client 1.53.2 → 1.54.0
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 +11 -0
- package/dist/index.browser.es.js +39 -7
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +39 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +39 -7
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/types.d.ts +6 -0
- package/dist/src/reporting/ClientEventReporter.d.ts +2 -0
- package/package.json +1 -1
- package/src/Call.ts +40 -5
- package/src/StreamVideoClient.ts +1 -0
- package/src/coordinator/connection/types.ts +7 -0
- package/src/reporting/ClientEventReporter.ts +4 -0
- package/src/reporting/__tests__/ClientEventReporter.test.ts +33 -0
- package/src/rtc/__tests__/Call.reconnect.test.ts +149 -2
package/dist/index.es.js
CHANGED
|
@@ -6641,7 +6641,7 @@ const getSdkVersion = (sdk) => {
|
|
|
6641
6641
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
6642
6642
|
};
|
|
6643
6643
|
|
|
6644
|
-
const version = "1.
|
|
6644
|
+
const version = "1.54.0";
|
|
6645
6645
|
const [major, minor, patch] = version.split('.');
|
|
6646
6646
|
let sdkInfo = {
|
|
6647
6647
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -14555,7 +14555,7 @@ class Call {
|
|
|
14555
14555
|
]);
|
|
14556
14556
|
const isReconnecting = this.reconnectStrategy !== WebsocketReconnectStrategy.UNSPECIFIED;
|
|
14557
14557
|
const reconnectDetails = isReconnecting
|
|
14558
|
-
? this.getReconnectDetails(
|
|
14558
|
+
? this.getReconnectDetails(previousSfuClient?.edgeName, previousSessionId)
|
|
14559
14559
|
: undefined;
|
|
14560
14560
|
const preferredPublishOptions = !isReconnecting
|
|
14561
14561
|
? this.getPreferredPublishOptions()
|
|
@@ -14924,6 +14924,7 @@ class Call {
|
|
|
14924
14924
|
const reconnectStartTime = Date.now();
|
|
14925
14925
|
this.reconnectStrategy = strategy;
|
|
14926
14926
|
this.reconnectReason = reason;
|
|
14927
|
+
const sfuRejoinFailures = new Map();
|
|
14927
14928
|
const markAsReconnectingFailed = async () => {
|
|
14928
14929
|
try {
|
|
14929
14930
|
// attempt to fetch the call data from the server, as the call
|
|
@@ -14982,7 +14983,8 @@ class Call {
|
|
|
14982
14983
|
if (this.reconnectStrategy !== WebsocketReconnectStrategy.FAST) {
|
|
14983
14984
|
this.reconnectAttempts++;
|
|
14984
14985
|
}
|
|
14985
|
-
const
|
|
14986
|
+
const attemptedStrategy = this.reconnectStrategy;
|
|
14987
|
+
const currentStrategy = WebsocketReconnectStrategy[attemptedStrategy];
|
|
14986
14988
|
try {
|
|
14987
14989
|
// wait until the network is available
|
|
14988
14990
|
await this.networkAvailableTask?.promise;
|
|
@@ -14995,9 +14997,24 @@ class Call {
|
|
|
14995
14997
|
case WebsocketReconnectStrategy.FAST:
|
|
14996
14998
|
await this.reconnectFast();
|
|
14997
14999
|
break;
|
|
14998
|
-
case WebsocketReconnectStrategy.REJOIN:
|
|
14999
|
-
|
|
15000
|
+
case WebsocketReconnectStrategy.REJOIN: {
|
|
15001
|
+
const confirmedBadSfus = Array.from(sfuRejoinFailures)
|
|
15002
|
+
.filter(([, failures]) => failures >= 2)
|
|
15003
|
+
.map(([sfu]) => sfu);
|
|
15004
|
+
if (this.joinCallData && confirmedBadSfus.length) {
|
|
15005
|
+
this.joinCallData.migrating_from =
|
|
15006
|
+
confirmedBadSfus[confirmedBadSfus.length - 1];
|
|
15007
|
+
this.joinCallData.migrating_from_list = confirmedBadSfus;
|
|
15008
|
+
}
|
|
15009
|
+
try {
|
|
15010
|
+
await this.reconnectRejoin();
|
|
15011
|
+
}
|
|
15012
|
+
finally {
|
|
15013
|
+
delete this.joinCallData?.migrating_from;
|
|
15014
|
+
delete this.joinCallData?.migrating_from_list;
|
|
15015
|
+
}
|
|
15000
15016
|
break;
|
|
15017
|
+
}
|
|
15001
15018
|
case WebsocketReconnectStrategy.MIGRATE:
|
|
15002
15019
|
await this.reconnectMigrate();
|
|
15003
15020
|
break;
|
|
@@ -15010,6 +15027,15 @@ class Call {
|
|
|
15010
15027
|
break; // do-while loop, reconnection worked, exit the loop
|
|
15011
15028
|
}
|
|
15012
15029
|
catch (error) {
|
|
15030
|
+
if (attemptedStrategy === WebsocketReconnectStrategy.REJOIN) {
|
|
15031
|
+
const failedSfu = this.credentials?.server.edge_name;
|
|
15032
|
+
if (failedSfu) {
|
|
15033
|
+
const switchSfu = error instanceof SfuJoinError &&
|
|
15034
|
+
SfuJoinError.isJoinErrorCode(error.errorEvent);
|
|
15035
|
+
const failures = (sfuRejoinFailures.get(failedSfu) ?? 0) + 1;
|
|
15036
|
+
sfuRejoinFailures.set(failedSfu, switchSfu ? Math.max(failures, 2) : failures);
|
|
15037
|
+
}
|
|
15038
|
+
}
|
|
15013
15039
|
if (this.state.callingState === CallingState.OFFLINE) {
|
|
15014
15040
|
this.logger.debug(`[Reconnect] Can't reconnect while offline, stopping reconnection attempts`);
|
|
15015
15041
|
break;
|
|
@@ -15205,6 +15231,8 @@ class Call {
|
|
|
15205
15231
|
this.state.setCallingState(CallingState.OFFLINE);
|
|
15206
15232
|
}
|
|
15207
15233
|
else {
|
|
15234
|
+
if (!this.networkAvailableTask)
|
|
15235
|
+
return;
|
|
15208
15236
|
this.logger.debug('[Reconnect] Going online');
|
|
15209
15237
|
this.sfuClient?.close(StreamSfuClient.DISPOSE_OLD_SOCKET, 'Closing WS to reconnect after going online');
|
|
15210
15238
|
// we went online, release the previous waiters and reset the state
|
|
@@ -17463,11 +17491,11 @@ class StreamClient {
|
|
|
17463
17491
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
17464
17492
|
};
|
|
17465
17493
|
this.getSdkVersion = () => this.options.clientAppIdentifier?.sdkVersion ||
|
|
17466
|
-
"1.
|
|
17494
|
+
"1.54.0";
|
|
17467
17495
|
this.getUserAgent = () => {
|
|
17468
17496
|
if (!this.cachedUserAgent) {
|
|
17469
17497
|
const { clientAppIdentifier = {} } = this.options;
|
|
17470
|
-
const { sdkName = 'js', sdkVersion = "1.
|
|
17498
|
+
const { sdkName = 'js', sdkVersion = "1.54.0", ...extras } = clientAppIdentifier;
|
|
17471
17499
|
this.cachedUserAgent = [
|
|
17472
17500
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
17473
17501
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
@@ -18145,6 +18173,8 @@ class ClientEventReporter {
|
|
|
18145
18173
|
};
|
|
18146
18174
|
};
|
|
18147
18175
|
this.send = (body) => {
|
|
18176
|
+
if (!this.enabled)
|
|
18177
|
+
return;
|
|
18148
18178
|
void this.sendWithRetry(body);
|
|
18149
18179
|
};
|
|
18150
18180
|
this.sendWithRetry = async (body) => {
|
|
@@ -18170,6 +18200,7 @@ class ClientEventReporter {
|
|
|
18170
18200
|
return false;
|
|
18171
18201
|
};
|
|
18172
18202
|
this.streamClient = options.streamClient;
|
|
18203
|
+
this.enabled = options.enabled ?? true;
|
|
18173
18204
|
}
|
|
18174
18205
|
}
|
|
18175
18206
|
const readPermissionStatus = (permission) => {
|
|
@@ -18650,6 +18681,7 @@ class StreamVideoClient {
|
|
|
18650
18681
|
this.streamClient = createCoordinatorClient(apiKey, clientOptions);
|
|
18651
18682
|
this.clientEventReporter = new ClientEventReporter({
|
|
18652
18683
|
streamClient: this.streamClient,
|
|
18684
|
+
enabled: clientOptions?.clientEventsReportingEnabled ?? true,
|
|
18653
18685
|
});
|
|
18654
18686
|
this.writeableStateStore = new StreamVideoWriteableStateStore();
|
|
18655
18687
|
this.readOnlyStateStore = new StreamVideoReadOnlyStateStore(this.writeableStateStore);
|