Empty reply after 2 minutes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 43.3k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I'm running a server with pm2 and a node/express application.
There are some computational expensive operations that require more than 2 minutes to give a response and I've used an express middleware called connect-timeout to set the request timeout to 5 minutes.
(I know it is not a good practice to keep the connection waiting for so long, but this is an internal tool/batch endpoint and it is acceptable).
I've ecountered this issue with pm2: even if the timeout is set to be longer than 2 minutes on the express side, the pm2 closes anyway the connection after 2 minutes.
I did a test using setTimeout and this is the minimal configuration for testing it:
const express = require('express');
const timeout = require('connect-timeout');
redis.flush();
const app = express();
app.use(timeout('5m'));
app.get('/testtimeout/:minutes?', (req, res) => {
const minutes = req.params.minutes ? parseInt(req.params.minutes) : 1;
setTimeout(() => {
res.send('done');
}, 1000 * 60 * minutes);
});
let port = 9018;
//start
app.listen(port, () => {
logger.log('* starting server');
logger.log('* env:', process.env.NODE_ENV);
logger.log('* port:', port);
logger.log('*** * * * ***');
});
module.exports = app;
then I run it by pm2
NODE_ENV=production pm2 start app.js -i 0 --name timeout-app
I use curl to test the endpoint:
curl localhost:9018/testtimeout/3
If the time is more than 2 minutes I get:
curl: (52) Empty reply from server
This doesn't happen if I run it in local using nodemon for developing.
Is there a way to extend this time to more than 2 minutes?
Thanks!
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 minimal app.js example and run the supplied pm2 start command, then compare it with the nodemon and curl behavior for requests lasting over two minutes. Trace PM2's handling of the request and document or verify the configuration needed for the three-minute request to return its response instead of an empty reply.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, node.js
- Domain
- backend, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100