aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wallet.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet.js b/src/wallet.js
index 2f65904..bc24393 100644
--- a/src/wallet.js
+++ b/src/wallet.js
@@ -1607,7 +1607,10 @@ export class Wallet {
// not responses). Newline-terminated per the protocol.
_rpcSend(method, params) {
if (!this._ws || this._ws.readyState !== 1) return;
- const id = ++this._rpcId;
+ // Coerce to a number defensively: a non-numeric _rpcId serializes id as
+ // null, which the response matcher (msg.id != null) drops — silently
+ // breaking every data call (and thus reconciles).
+ const id = (this._rpcId = (this._rpcId || 0) + 1);
try {
this._ws.send(JSON.stringify({ id, method, params }) + '\n');
} catch {}
@@ -1642,7 +1645,7 @@ export class Wallet {
_rpcSendCall(method, params, attempt = 0) {
return new Promise((resolve, reject) => {
if (this.offline) { reject(new Error('offline')); return; }
- const id = ++this._rpcId;
+ const id = (this._rpcId = (this._rpcId || 0) + 1);
if (!this._pending) this._pending = new Map();
const timer = setTimeout(() => {
if (!this._pending.delete(id)) return;