restify / restify/node-restify

Using pre.pause() causes multipart body processing to fail

Open
#1,848 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.7k
Forks
975
Avg merge
1d 6h
Merged PRs (30d)
5

Description

If I am using pre.pause() to deal with the similar issues reported in:

https://github.com/restify/node-restify/issues/287
https://github.com/restify/node-restify/issues/409

it appears that having that work-around causes the multipart body processing to fail.

Restify never calls my route function and eventually times out returning a 444 error.

Simple Server code:

const restify = require('restify');

const server = restify.createServer({
    name: 'myServer',
});

// *********************************
// comment out following to fix 
server.pre(restify.pre.pause());
// *********************************

server.use(restify.plugins.bodyParser({
    mapParams: true,
    mapFiles: true,
    keepExtensions: true,
    uploadDir: '/tmp/',
}));
server.use(restify.plugins.queryParser({ mapParams: true }));

server.post("/upload", function (request, response, next) {
    response.send("steve");
    next();
});

server.listen(8372, () => console.log('Server started on port 8372'));

calling with a file and data:

curl --request POST 'http://localhost:8372/api/upload' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@/Users/steve/Downloads/myfile.jpg' \
--form 'data=mine'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with server.pre(restify.pre.pause()), the bodyParser configuration, and the multipart curl request shown. Trace why the POST /upload route is not reached; done means multipart fields and files are processed and the route returns its response without timing out or producing a 444 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.