engine.io incompatible with restify – engine.io assumes req.query is query hash #203

timoxley opened this Issue Nov 24, 2013 · 9 comments


None yet

3 participants


Engine.io assumes if req.query exists that it is an object containing the parsed query:

// transport check
var transport = req.query.transport;
if (!~this.transports.indexOf(transport)) {

Alas, in restify, req.queryis a function.

Request.prototype.query = Request.prototype.getQuery;

This makes engine.io sad as it cannot find its transports:

handling "GET" http request "/result-preview/?EIO=2&transport=polling"
unknown transport "undefined"

Looking for advice on how to solve this issue without hacking modules up.

Perhaps engine.io could also check that .query is an object with the properties engine.io needs, or simply make no assumptions and parse the query string for each request.

Related code in restify:

Related code in engine.io:


FYI I've opened a reciprocal issue on restify: restify/node-restify#486


Awful decision on our side. We shouldn't touch req in this obtrusive way.


(it was my decision btw :P)


@guille what's the alternative here? engine.io seems to extensively use the req as a namespace for sharing data, you'd need to move to more 'pure' functions or perhaps utilising some kind of wrapper that prevents modification of the original req, e.g. wrapping it in Object.create(req)


maybe all custom properties should be namespaced under req.engineio


@3rd-Eden yep, that's probably the simplest solution. Is there another way though? Although it's the norm, treating req as a dumping ground is a probably a pretty crappy practice in the first place.


@timoxley ideally we have a helper that just returns the query object from the request, and we don't touch it


@guille ok, req.query is used in multiple locations, but I guess it's probably not so much of a performance hit to just calculate it on the fly.

Also, something similar should probably be done with these other properties attached to the req:



@rauchg rauchg closed this in 0743f32 Apr 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment