diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-19 14:31:45 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-07-21 09:31:39 -0700 |
commit | f053feb6d4aba1eaa44a35d050522b641c011b33 (patch) | |
tree | 30df581b0cb01ebaa33e4311608254345010c8e8 | |
parent | 9d22ac82811899ed4e806c1941f2a5695e414612 (diff) | |
download | qtlocation-mapboxgl-f053feb6d4aba1eaa44a35d050522b641c011b33.tar.gz |
[node] Protect against synchronous request implementations
-rw-r--r-- | platform/node/index.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/platform/node/index.js b/platform/node/index.js index 54ba5c0dc6..e36a47943d 100644 --- a/platform/node/index.js +++ b/platform/node/index.js @@ -4,6 +4,7 @@ var mbgl = require('../../lib/mapbox_gl_native.node'); var constructor = mbgl.Map.prototype.constructor; +var process = require('process'); var Map = function(options) { if (!(options instanceof Object)) { @@ -19,7 +20,12 @@ var Map = function(options) { return new constructor(Object.assign(options, { request: function(req) { request(req, function() { - req.respond.apply(req, arguments); + var args = arguments; + // Protect against `request` implementations that call the callback synchronously. + // http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony + process.nextTick(function() { + req.respond.apply(req, args); + }); }); } })); |