@reactoo/watchtogether-sdk-js 2.8.6 → 2.8.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.8.6",
3
+ "version": "2.8.7",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
@@ -941,6 +941,9 @@ class RoomSession {
941
941
  }
942
942
  return json;
943
943
  })
944
+ .catch(e => {
945
+ return Promise.reject({error: e, requestData});
946
+ })
944
947
  }
945
948
 
946
949
  async #sendWebsockets(request = {}, ignoreResponse = false, dontResolveOnAck = false, retry = 0) {
@@ -1002,10 +1005,10 @@ class RoomSession {
1002
1005
  })
1003
1006
 
1004
1007
  return op().catch(e => {
1005
- if (e.id === 17) {
1008
+ if (e.id === 4 ) {
1006
1009
  return Promise.reject(e);
1007
1010
  }
1008
- else if(e.id === 29 && retry > 0) {
1011
+ else if(e.id === 7 && retry > 0) {
1009
1012
  return wait(this._sendMessageTimeout).then(() => this.#send(request, ignoreResponse, dontResolveOnAck, retry - 1));
1010
1013
  }
1011
1014
  else if(retry > 0) {
@@ -1841,10 +1844,10 @@ class RoomSession {
1841
1844
  }
1842
1845
  let _rejectTimeout = () => {
1843
1846
  cleanup();
1844
- reject({type: 'warning', id: 44, message: 'Connection timeout'})
1847
+ reject({type: 'error', id: 44, message: 'Connection timeout'})
1845
1848
  }
1846
1849
  this.once('joined', _resolve);
1847
- timeoutId = setTimeout(_rejectTimeout, 10000)
1850
+ timeoutId = setTimeout(_rejectTimeout, 15000)
1848
1851
  this._abortController.signal.addEventListener('abort', _rejectAbort);
1849
1852
  })
1850
1853
  }
@@ -1953,6 +1956,9 @@ class RoomSession {
1953
1956
  await this.#waitForConnectEvent();
1954
1957
 
1955
1958
  } catch (error) {
1959
+ if(error?.type !== 'warning') {
1960
+ this.disconnect().catch(() => {});
1961
+ }
1956
1962
  this.emit('error', error);
1957
1963
  } finally {
1958
1964
  this.isConnecting = false;