starknet 10.6.4 → 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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [10.6.6](https://github.com/starknet-io/starknet.js/compare/v10.6.5...v10.6.6) (2026-08-05)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **ws:** reject queued requests instead of hanging ([82ced97](https://github.com/starknet-io/starknet.js/commit/82ced97dc6dc409131bc5650db076efedf467101))
6
+
7
+ ## [10.6.5](https://github.com/starknet-io/starknet.js/compare/v10.6.4...v10.6.5) (2026-08-05)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **ws:** guard malformed frames and honour request id 0 ([cf1f4e2](https://github.com/starknet-io/starknet.js/commit/cf1f4e2c1f58eba5f1d63628959fe2ee47387025))
12
+
1
13
  ## [10.6.4](https://github.com/starknet-io/starknet.js/compare/v10.6.3...v10.6.4) (2026-08-04)
2
14
 
3
15
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -5243,6 +5243,16 @@ declare class WebSocketChannel {
5243
5243
  */
5244
5244
  reconnect(): void;
5245
5245
  private _processRequestQueue;
5246
+ /**
5247
+ * Reject every request still waiting in the queue.
5248
+ *
5249
+ * A queued request carries no timeout of its own: the `requestTimeout` timer is only
5250
+ * armed once the request is actually put on the wire. So once the channel reaches a state
5251
+ * where the queue can never be flushed — reconnection gave up, or the user closed the
5252
+ * connection — the queued promises would stay pending forever, and no caller-side timeout
5253
+ * could rescue them. Settling them here is the only way out.
5254
+ */
5255
+ private _rejectRequestQueue;
5246
5256
  private _restoreSubscriptions;
5247
5257
  /**
5248
5258
  * Reset the reconnection attempt counter, but only once the current connection has
@@ -12654,7 +12654,7 @@ ${indent}}` : "}";
12654
12654
  this.websocket.addEventListener("error", this.errorListener);
12655
12655
  }
12656
12656
  idResolver(id) {
12657
- if (id) return id;
12657
+ if (id !== void 0) return id;
12658
12658
  return this.sendId++;
12659
12659
  }
12660
12660
  /**
@@ -12712,7 +12712,15 @@ ${indent}}` : "}";
12712
12712
  logger.warn("WebSocket received non-string message data:", event.data);
12713
12713
  return;
12714
12714
  }
12715
- const message = JSON.parse(event.data);
12715
+ let message;
12716
+ try {
12717
+ message = JSON.parse(event.data);
12718
+ } catch (error) {
12719
+ logger.error(
12720
+ `WebSocketChannel: Error parsing incoming message: ${event.data}, Error: ${error}`
12721
+ );
12722
+ return;
12723
+ }
12716
12724
  if (message.id === sendId) {
12717
12725
  clearTimeout(timeoutId);
12718
12726
  this.websocket.removeEventListener("message", messageHandler);
@@ -12795,6 +12803,8 @@ ${indent}}` : "}";
12795
12803
  this.reconnectStabilityTimeoutId = null;
12796
12804
  }
12797
12805
  this.userInitiatedClose = true;
12806
+ this.isReconnecting = false;
12807
+ this._rejectRequestQueue("the connection was closed by the user");
12798
12808
  this.websocket.close(code, reason);
12799
12809
  }
12800
12810
  /**
@@ -12868,6 +12878,24 @@ ${indent}}` : "}";
12868
12878
  this.sendReceive(method, params).then(resolve).catch(reject);
12869
12879
  });
12870
12880
  }
12881
+ /**
12882
+ * Reject every request still waiting in the queue.
12883
+ *
12884
+ * A queued request carries no timeout of its own: the `requestTimeout` timer is only
12885
+ * armed once the request is actually put on the wire. So once the channel reaches a state
12886
+ * where the queue can never be flushed — reconnection gave up, or the user closed the
12887
+ * connection — the queued promises would stay pending forever, and no caller-side timeout
12888
+ * could rescue them. Settling them here is the only way out.
12889
+ */
12890
+ _rejectRequestQueue(reason) {
12891
+ if (this.requestQueue.length === 0) return;
12892
+ const pending = this.requestQueue;
12893
+ this.requestQueue = [];
12894
+ logger.info(`WebSocket: Rejecting ${pending.length} queued request(s). Reason: ${reason}.`);
12895
+ pending.forEach(({ method, reject }) => {
12896
+ reject(new WebSocketNotConnectedError(`Request ${method} was never sent: ${reason}`));
12897
+ });
12898
+ }
12871
12899
  async _restoreSubscriptions() {
12872
12900
  const oldSubscriptions = Array.from(this.activeSubscriptions.values());
12873
12901
  this.activeSubscriptions.clear();
@@ -12911,6 +12939,9 @@ ${indent}}` : "}";
12911
12939
  if (this.reconnectAttempts >= this.reconnectOptions.retries) {
12912
12940
  logger.error("WebSocket: Maximum reconnection retries reached. Giving up.");
12913
12941
  this.isReconnecting = false;
12942
+ this._rejectRequestQueue(
12943
+ `reconnection gave up after ${this.reconnectOptions.retries} attempts`
12944
+ );
12914
12945
  return;
12915
12946
  }
12916
12947
  this.reconnectAttempts += 1;