Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading… incompatible with restify – assumes req.query is query hash #203

timoxley opened this Issue · 9 comments

3 participants

@timoxley 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 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 could also check that .query is an object with the properties needs, or simply make no assumptions and parse the query string for each request.

Related code in restify:

Related code in


FYI I've opened a reciprocal issue on restify: mcavage/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? 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.