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 +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.global.js +33 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7430,7 +7430,7 @@ var WebSocketChannel = class {
|
|
|
7430
7430
|
this.websocket.addEventListener("error", this.errorListener);
|
|
7431
7431
|
}
|
|
7432
7432
|
idResolver(id) {
|
|
7433
|
-
if (id) return id;
|
|
7433
|
+
if (id !== void 0) return id;
|
|
7434
7434
|
return this.sendId++;
|
|
7435
7435
|
}
|
|
7436
7436
|
/**
|
|
@@ -7488,7 +7488,15 @@ var WebSocketChannel = class {
|
|
|
7488
7488
|
logger.warn("WebSocket received non-string message data:", event.data);
|
|
7489
7489
|
return;
|
|
7490
7490
|
}
|
|
7491
|
-
|
|
7491
|
+
let message;
|
|
7492
|
+
try {
|
|
7493
|
+
message = JSON.parse(event.data);
|
|
7494
|
+
} catch (error) {
|
|
7495
|
+
logger.error(
|
|
7496
|
+
`WebSocketChannel: Error parsing incoming message: ${event.data}, Error: ${error}`
|
|
7497
|
+
);
|
|
7498
|
+
return;
|
|
7499
|
+
}
|
|
7492
7500
|
if (message.id === sendId) {
|
|
7493
7501
|
clearTimeout(timeoutId);
|
|
7494
7502
|
this.websocket.removeEventListener("message", messageHandler);
|
|
@@ -7571,6 +7579,8 @@ var WebSocketChannel = class {
|
|
|
7571
7579
|
this.reconnectStabilityTimeoutId = null;
|
|
7572
7580
|
}
|
|
7573
7581
|
this.userInitiatedClose = true;
|
|
7582
|
+
this.isReconnecting = false;
|
|
7583
|
+
this._rejectRequestQueue("the connection was closed by the user");
|
|
7574
7584
|
this.websocket.close(code, reason);
|
|
7575
7585
|
}
|
|
7576
7586
|
/**
|
|
@@ -7644,6 +7654,24 @@ var WebSocketChannel = class {
|
|
|
7644
7654
|
this.sendReceive(method, params).then(resolve).catch(reject);
|
|
7645
7655
|
});
|
|
7646
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
|
+
}
|
|
7647
7675
|
async _restoreSubscriptions() {
|
|
7648
7676
|
const oldSubscriptions = Array.from(this.activeSubscriptions.values());
|
|
7649
7677
|
this.activeSubscriptions.clear();
|
|
@@ -7687,6 +7715,9 @@ var WebSocketChannel = class {
|
|
|
7687
7715
|
if (this.reconnectAttempts >= this.reconnectOptions.retries) {
|
|
7688
7716
|
logger.error("WebSocket: Maximum reconnection retries reached. Giving up.");
|
|
7689
7717
|
this.isReconnecting = false;
|
|
7718
|
+
this._rejectRequestQueue(
|
|
7719
|
+
`reconnection gave up after ${this.reconnectOptions.retries} attempts`
|
|
7720
|
+
);
|
|
7690
7721
|
return;
|
|
7691
7722
|
}
|
|
7692
7723
|
this.reconnectAttempts += 1;
|