diff --git a/lib/client.js b/lib/client.js index f068f0b..9f576ec 100644 --- a/lib/client.js +++ b/lib/client.js @@ -155,7 +155,15 @@ class Client { callback(null, msg.result || msg); } } else { - console.log("Can't get callback"); + console.log("Electrum: can't get callback. Msg = " + JSON.stringify(msg)); + if (JSON.stringify(msg).includes("Batch limit exceeded")) { + // since we dont know which batch failed (id is not provided), we cancel all requests. + // this is better than hanging indefinitely + Object.keys(this.callback_message_queue).forEach(key => { + this.callback_message_queue[key](new Error('Batch limit exceeded')); + delete this.callback_message_queue[key]; + }); + } } } diff --git a/package.json b/package.json index b259bf1..973c72c 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "electrum-client", - "version": "3.1.0", + "version": "3.1.1", "description": "Electrum protocol client for React Native & Node.js", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "node test.js" }, "dependencies": {}, "devDependencies": {},