summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-07-19 14:31:45 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-07-21 09:31:39 -0700
commitf053feb6d4aba1eaa44a35d050522b641c011b33 (patch)
tree30df581b0cb01ebaa33e4311608254345010c8e8 /platform
parent9d22ac82811899ed4e806c1941f2a5695e414612 (diff)
downloadqtlocation-mapboxgl-f053feb6d4aba1eaa44a35d050522b641c011b33.tar.gz
[node] Protect against synchronous request implementations
Diffstat (limited to 'platform')
-rw-r--r--platform/node/index.js8
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);
+ });
});
}
}));