Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restify Server will not respond to GET request when the URI is >=200 characters #1855

Closed
3 tasks done
reediculous456 opened this issue Aug 11, 2020 · 2 comments
Closed
3 tasks done

Comments

@reediculous456
Copy link

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

Restify Version: 8.5.1
Node.js Version: 12.18.3

Expected behaviour

I expected that I would be able to send a GET request with a URI longer than 200 characters

Actual behaviour

The code I wrote works find as long as the total URI with all query-string parameters is < 200 characters, but when the URI goes over 200 characters then the route hangs for the client and the server acts like it never even receives the request

Repro case

Server Declaration:

const { createServer, plugins, pre } = require(`restify`);
const pkg = require(`../package.json`);

const server = createServer({
  ignoreTrailingSlash: true, // added as part of debugging
  maxParamLength: 1000, // added as part of debugging
  name: pkg.name,
  version: pkg.version,
});
server.server.setTimeout(0);
server.pre(pre.sanitizePath());
server.use(plugins.acceptParser(server.acceptable));
server.use(plugins.dateParser());
server.use(plugins.queryParser({
  arrayLimit: 1000, // added as part of debugging
  mapParams: true,
  parameterLimit: 1000, // added as part of debugging
}));
server.use(plugins.jsonp());
server.use(plugins.gzipResponse());
server.use(plugins.bodyParser({
  hash: `sha1`,
  keepExtensions: true,
  mapFiles: false,
  mapParams: false,
  maxBodySize: 1000, // added as part of debugging
  maxFieldsSize: 2 * 1024 * 1024 * 1024, // added as part of debugging
  multiples: true,
  reviver: undefined,
  uploadDir: path.resolve(`${process.cwd()}/temp`),
}));

Route

  server.get(
    `/vendor-markup/box-floors/sum`,
    async (req, res, next) => {
      try {
        const { a, b } = req.params;
        ...
        use the params and send response
        ...
      } catch (err) {
        next(err);
      }
    },
  );

Postman examples

I have also tested this using restify-clients.createJsonClient and get the same results

199 chars, works

http://localhost:3000/vendor-markup/box-floors/sum?a=2880&a=2881&a=2882&a=2883&a=2872&a=2873&a=2874&a=2875&a=2876&a=2877&a=2866&a=2867&a=2868&a=2869&a=2870&a=2859&a=2860&a=2861&a=2871&a=2865&b=23&a=1

200 chars, doesn't work

http://localhost:3000/vendor-markup/box-floors/sum?a=2880&a=2881&a=2882&a=2883&a=2872&a=2873&a=2874&a=2875&a=2876&a=2877&a=2866&a=2867&a=2868&a=2869&a=2870&a=2859&a=2860&a=2861&a=2871&a=2865&b=23&a=11

Cause

I have dug through much of the source code and believe this is not an issue with find-my-way (as described in #1677) and it is not an issue with the queryParser plugin. Neither of these two libraries seem to receive the request when it breaks the 200 character limit

Are you willing and able to fix this?

I am willing to help fix this, however I have never looked much into the restify source code and need help pinpointing exactly what is causing this problem.

@reediculous456
Copy link
Author

As an update, this appears to be a UNIX issue. I see this when running restify of MacOS and Linux, but not on windows

@reediculous456
Copy link
Author

Finally found my solution. This is an issue with NodeJS and not Restify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant