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