Fix duplicate text bug on reconnect or ACK timeout

This commit is contained in:
yflory
2020-03-16 11:19:04 +01:00
parent a2b6501adb
commit 27c1291182
3 changed files with 11 additions and 6 deletions

View File

@@ -45,10 +45,13 @@ define([
var txid = mkTxid();
opts = opts || {};
var to = opts.timeout || 30000;
var timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
var timeout;
if (to > 0) {
timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
}
acks[txid] = function (err) {
clearTimeout(timeout);
delete acks[txid];