restify / restify/node-restify
Side-effect behavior on `req.query` when requiring restify
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
Restify versions: v6.2.3 to v5.0.1 (v4.3.1 unaffected)
Node.js version: v6.11.3
This bug affects applications that will through the dependency tree require both restify and express somewhere, for example if you have an express application that uses restify as a client to another service, or is even just a dependency and not used directly. This may affect other http libraries but that has not been tested.
The unexpected behavior I noticed was that req.query was a function when it should be an object within express. This lead to unexplainable behavior that req.query.skip was undefined, even though that query variable exists. An upgrade from v4 of restify to v6 was identified as the cause for this behavior change.
The issue is reproducible with express at version v4.16.2 and restify above v4.3.1. So there is something that was introduced between v4.3.1 and v5.0.1 of restify that broke things. I've been able to reproduce this by running the express tests at https://github.com/expressjs/express/releases/tag/4.16.2 and adding this to the index.js file before running tests:
const restify = require('restify');
module.exports = require('./lib/express');
I have not yet dug into the specific reason as there are many commits between these two releases, and opening this issue in case anyone may have an idea to what's causing this before digging through the commits.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction described in the issue: add the restify require to express's index.js and run the Express v4.16.2 tests. Compare restify v4.3.1 with the affected v5.0.1–v6.2.3 versions to identify the change that alters req.query. Done means the Express tests pass and req.query remains an object with query values available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100