FIX: dont hang forever if electrum threw 'Batch limit exceeded' error

This commit is contained in:
overtorment 2025-05-16 16:53:49 +01:00
parent 1bfe3cc424
commit d9f511d97f
2 changed files with 11 additions and 3 deletions

View File

@ -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];
});
}
}
}

View File

@ -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": {},