@hocuspocus/provider 2.3.0 → 2.3.1

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.
@@ -1693,6 +1693,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1693
1693
  this.receivedOnOpenPayload = undefined;
1694
1694
  this.receivedOnStatusPayload = undefined;
1695
1695
  this.boundConnect = this.connect.bind(this);
1696
+ this.closeTries = 0;
1696
1697
  this.setConfiguration(configuration);
1697
1698
  this.configuration.WebSocketPolyfill = configuration.WebSocketPolyfill ? configuration.WebSocketPolyfill : WebSocket;
1698
1699
  this.on('open', this.configuration.onOpen);
@@ -1854,8 +1855,21 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1854
1855
  }
1855
1856
  // No message received in a long time, not even your own
1856
1857
  // Awareness updates, which are updated every 15 seconds.
1857
- (_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.close();
1858
- this.messageQueue = [];
1858
+ this.closeTries += 1;
1859
+ // https://bugs.webkit.org/show_bug.cgi?id=247943
1860
+ if (this.closeTries > 2) {
1861
+ this.onClose({
1862
+ event: {
1863
+ code: 4408,
1864
+ reason: 'forced',
1865
+ },
1866
+ });
1867
+ this.closeTries = 0;
1868
+ }
1869
+ else {
1870
+ (_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.close();
1871
+ this.messageQueue = [];
1872
+ }
1859
1873
  }
1860
1874
  registerEventListeners() {
1861
1875
  if (typeof window === 'undefined') {
@@ -1897,6 +1911,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
1897
1911
  }
1898
1912
  }
1899
1913
  onClose({ event }) {
1914
+ this.closeTries = 0;
1900
1915
  this.webSocket = null;
1901
1916
  if (this.status === exports.WebSocketStatus.Connected) {
1902
1917
  this.status = exports.WebSocketStatus.Disconnected;