@stream-io/video-client 1.27.2 → 1.27.3

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/dist/index.es.js CHANGED
@@ -5915,7 +5915,7 @@ const aggregate = (stats) => {
5915
5915
  return report;
5916
5916
  };
5917
5917
 
5918
- const version = "1.27.2";
5918
+ const version = "1.27.3";
5919
5919
  const [major, minor, patch] = version.split('.');
5920
5920
  let sdkInfo = {
5921
5921
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -7634,19 +7634,22 @@ class Subscriber extends BasePeerConnection {
7634
7634
  }
7635
7635
 
7636
7636
  const createWebSocketSignalChannel = (opts) => {
7637
- const { endpoint, onMessage, tag } = opts;
7637
+ const { endpoint, onMessage, tag, tracer } = opts;
7638
7638
  const logger = getLogger(['SfuClientWS', tag]);
7639
7639
  logger('debug', 'Creating signaling WS channel:', endpoint);
7640
7640
  const ws = new WebSocket(endpoint);
7641
7641
  ws.binaryType = 'arraybuffer'; // do we need this?
7642
7642
  ws.addEventListener('error', (e) => {
7643
7643
  logger('error', 'Signaling WS channel error', e);
7644
+ tracer?.trace('signal.ws.error', e);
7644
7645
  });
7645
7646
  ws.addEventListener('close', (e) => {
7646
7647
  logger('info', 'Signaling WS channel is closed', e);
7648
+ tracer?.trace('signal.ws.close', e);
7647
7649
  });
7648
7650
  ws.addEventListener('open', (e) => {
7649
7651
  logger('info', 'Signaling WS channel is open', e);
7652
+ tracer?.trace('signal.ws.open', e);
7650
7653
  });
7651
7654
  ws.addEventListener('message', (e) => {
7652
7655
  try {
@@ -7656,7 +7659,9 @@ const createWebSocketSignalChannel = (opts) => {
7656
7659
  onMessage(message);
7657
7660
  }
7658
7661
  catch (err) {
7659
- logger('error', 'Failed to decode a message. Check whether the Proto models match.', { event: e, error: err });
7662
+ const message = 'Failed to decode a message. Check whether the Proto models match.';
7663
+ logger('error', message, { event: e, error: err });
7664
+ tracer?.trace('signal.ws.message.error', message);
7660
7665
  }
7661
7666
  });
7662
7667
  return ws;
@@ -7928,6 +7933,7 @@ class StreamSfuClient {
7928
7933
  this.signalWs = createWebSocketSignalChannel({
7929
7934
  tag: this.tag,
7930
7935
  endpoint: `${this.credentials.server.ws_endpoint}?${new URLSearchParams(params).toString()}`,
7936
+ tracer: this.tracer,
7931
7937
  onMessage: (message) => {
7932
7938
  this.lastMessageTimestamp = new Date();
7933
7939
  this.scheduleConnectionCheck();
@@ -7938,9 +7944,13 @@ class StreamSfuClient {
7938
7944
  this.dispatcher.dispatch(message, this.tag);
7939
7945
  },
7940
7946
  });
7947
+ let timeoutId;
7941
7948
  this.signalReady = makeSafePromise(Promise.race([
7942
7949
  new Promise((resolve, reject) => {
7950
+ let didOpen = false;
7943
7951
  const onOpen = () => {
7952
+ didOpen = true;
7953
+ clearTimeout(timeoutId);
7944
7954
  this.signalWs.removeEventListener('open', onOpen);
7945
7955
  resolve(this.signalWs);
7946
7956
  };
@@ -7948,19 +7958,25 @@ class StreamSfuClient {
7948
7958
  this.signalWs.addEventListener('close', (e) => {
7949
7959
  this.handleWebSocketClose(e);
7950
7960
  // Normally, this shouldn't have any effect, because WS should never emit 'close'
7951
- // before emitting 'open'. However, strager things have happened, and we don't
7952
- // want to leave signalReady in pending state.
7953
- reject(new Error(`SFU WS closed or connection can't be established`));
7961
+ // before emitting 'open'. However, stranger things have happened, and we don't
7962
+ // want to leave signalReady in a pending state.
7963
+ const message = didOpen
7964
+ ? `SFU WS closed: ${e.code} ${e.reason}`
7965
+ : `SFU WS connection can't be established: ${e.code} ${e.reason}`;
7966
+ this.tracer?.trace('signal.close', message);
7967
+ clearTimeout(timeoutId);
7968
+ reject(new Error(message));
7954
7969
  });
7955
7970
  }),
7956
7971
  new Promise((resolve, reject) => {
7957
- setTimeout(() => reject(new Error('SFU WS connection timed out')), this.joinResponseTimeout);
7972
+ timeoutId = setTimeout(() => {
7973
+ const message = `SFU WS connection failed to open after ${this.joinResponseTimeout}ms`;
7974
+ this.tracer?.trace('signal.timeout', message);
7975
+ reject(new Error(message));
7976
+ }, this.joinResponseTimeout);
7958
7977
  }),
7959
7978
  ]));
7960
7979
  };
7961
- this.cleanUpWebSocket = () => {
7962
- this.signalWs.removeEventListener('close', this.handleWebSocketClose);
7963
- };
7964
7980
  this.handleWebSocketClose = (e) => {
7965
7981
  this.signalWs.removeEventListener('close', this.handleWebSocketClose);
7966
7982
  getTimers().clearInterval(this.keepAliveInterval);
@@ -7972,7 +7988,7 @@ class StreamSfuClient {
7972
7988
  if (this.signalWs.readyState === WebSocket.OPEN) {
7973
7989
  this.logger('debug', `Closing SFU WS connection: ${code} - ${reason}`);
7974
7990
  this.signalWs.close(code, `js-client: ${reason}`);
7975
- this.cleanUpWebSocket();
7991
+ this.signalWs.removeEventListener('close', this.handleWebSocketClose);
7976
7992
  }
7977
7993
  this.dispose();
7978
7994
  };
@@ -14497,7 +14513,7 @@ class StreamClient {
14497
14513
  this.getUserAgent = () => {
14498
14514
  if (!this.cachedUserAgent) {
14499
14515
  const { clientAppIdentifier = {} } = this.options;
14500
- const { sdkName = 'js', sdkVersion = "1.27.2", ...extras } = clientAppIdentifier;
14516
+ const { sdkName = 'js', sdkVersion = "1.27.3", ...extras } = clientAppIdentifier;
14501
14517
  this.cachedUserAgent = [
14502
14518
  `stream-video-${sdkName}-v${sdkVersion}`,
14503
14519
  ...Object.entries(extras).map(([key, value]) => `${key}=${value}`),