starknet 10.6.5 → 10.6.6

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.mjs CHANGED
@@ -7579,6 +7579,8 @@ var WebSocketChannel = class {
7579
7579
  this.reconnectStabilityTimeoutId = null;
7580
7580
  }
7581
7581
  this.userInitiatedClose = true;
7582
+ this.isReconnecting = false;
7583
+ this._rejectRequestQueue("the connection was closed by the user");
7582
7584
  this.websocket.close(code, reason);
7583
7585
  }
7584
7586
  /**
@@ -7652,6 +7654,24 @@ var WebSocketChannel = class {
7652
7654
  this.sendReceive(method, params).then(resolve).catch(reject);
7653
7655
  });
7654
7656
  }
7657
+ /**
7658
+ * Reject every request still waiting in the queue.
7659
+ *
7660
+ * A queued request carries no timeout of its own: the `requestTimeout` timer is only
7661
+ * armed once the request is actually put on the wire. So once the channel reaches a state
7662
+ * where the queue can never be flushed — reconnection gave up, or the user closed the
7663
+ * connection — the queued promises would stay pending forever, and no caller-side timeout
7664
+ * could rescue them. Settling them here is the only way out.
7665
+ */
7666
+ _rejectRequestQueue(reason) {
7667
+ if (this.requestQueue.length === 0) return;
7668
+ const pending = this.requestQueue;
7669
+ this.requestQueue = [];
7670
+ logger.info(`WebSocket: Rejecting ${pending.length} queued request(s). Reason: ${reason}.`);
7671
+ pending.forEach(({ method, reject }) => {
7672
+ reject(new WebSocketNotConnectedError(`Request ${method} was never sent: ${reason}`));
7673
+ });
7674
+ }
7655
7675
  async _restoreSubscriptions() {
7656
7676
  const oldSubscriptions = Array.from(this.activeSubscriptions.values());
7657
7677
  this.activeSubscriptions.clear();
@@ -7695,6 +7715,9 @@ var WebSocketChannel = class {
7695
7715
  if (this.reconnectAttempts >= this.reconnectOptions.retries) {
7696
7716
  logger.error("WebSocket: Maximum reconnection retries reached. Giving up.");
7697
7717
  this.isReconnecting = false;
7718
+ this._rejectRequestQueue(
7719
+ `reconnection gave up after ${this.reconnectOptions.retries} attempts`
7720
+ );
7698
7721
  return;
7699
7722
  }
7700
7723
  this.reconnectAttempts += 1;