From 25acb4d62c7ad130a02f3ede767f3f08fa9ec896 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 19 Jul 2017 14:31:45 -0700 Subject: [node] Protect against synchronous request implementations --- platform/node/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/node/index.js b/platform/node/index.js index 54ba5c0dc6..5902f0bf59 100644 --- a/platform/node/index.js +++ b/platform/node/index.js @@ -19,7 +19,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 ourselves from `request` implementations that try to release Zalgo. + // http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony + setImmediate(function() { + req.respond.apply(req, args); + }); }); } })); -- cgit v1.2.1