diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 21d91aff..344bcfaf 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -876,7 +876,7 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre //q.pause(); //pause and wait until queue is set function chunkCallback(err, tx){ - console.debug("CHUNK", td_count, q.length()); + console.debug("CHUNK", td_count, q.length(), q.idle()); if(!err && !tx) //no error or tx data (duplicate calls will have empty tx value) return; @@ -944,11 +944,7 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre }); txIdTransformStream.on('end', function() { - q.drain = (e, d)=> { - console.debug("END-DRAIN", e, d, d_count, td_count); - next(); - }; - //q.resume(); + next(); }); txIdTransformStream._transform = function(chunk, enc, cb) { @@ -991,6 +987,15 @@ AddressService.prototype._streamAddressSummary = function(address, options, stre next(); }, + //wait for queue to complete + function(next) { + console.debug("WAITING FOR DRAIN") + q.drain = ()=> { + console.debug("END-DRAIN", d_count, td_count); + next(); + }; + } + ], callback); }