From 3967adcb4a2eb0d26f070e2574e4fb781b071399 Mon Sep 17 00:00:00 2001 From: Andrew Pendleton Date: Wed, 30 Mar 2016 01:10:20 -0400 Subject: [PATCH] Avoid callstack loop by making sure only one geocoder data iterator buffer-flush operation is happening at once --- lib/mbtiles.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mbtiles.js b/lib/mbtiles.js index 6647b71..b178a07 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -625,7 +625,11 @@ MBTiles.prototype.geocoderDataIterator = function(type) { var doneSentinel = {}; var _this = this; + var sending = false; var sendIfAvailable = function() { + if (sending) return; + sending = true; + while (nextQueue.length && dataQueue.length) { var nextCb = nextQueue.shift(), data; if (dataQueue[0] == doneSentinel) { @@ -637,6 +641,8 @@ MBTiles.prototype.geocoderDataIterator = function(type) { nextCb({value: {shard: data.shard, data: zlib.inflateSync(data.data)}, done: false}); } } + + sending = false; } var refilling = false;