Description
Today, Node.js http servers timeout and close the socket after 2 minutes. This means that if a request needs to do work that takes longer than 2 minutes to complete; the socket would be unceremoniously closed and the client will get an empty response.
$ curl localhost:8080
curl: (52) Empty reply from server
This is a common problem (search results) that users have to work-around (but most don't know about it). This is specially problematic in serverless environments where users may be doing non-interactive event processing (e.g. photo / image transcoding, uploading large datasets somewhere). Users have to know that this problem is possible and must adjust the timeout to make sure the service works correctly.
This is problematic for PaaS hosting providers where the best we can do is document to our users that timeout must be adjusted. This is specially a problem for serverless containers (e.g. Google Cloud Run).
IMO the default value should be removed:
- Node.js seems to be the only environment where this timeout exists. Here's comparable HTTP server code in Ruby, Python, Rust, Go and Node.js for a request that takes ~10 minutes of work. Only the Node.js example terminates the socket unceremoniously.
- The timeout value of 120sec was added very early on in the history of the Node.js project, but no clear rationale was articulated for why the timeout should exist.
I would like propose that we remove the timeout. I am working on a PR to do so. Alternatively, If there is strong reason for us to have a default timeout value, let's clearly articulate the reason, and at least provide environment knobs to allow e.g. Serverless hosts to configure a different default value.
Thoughts? Opinions?
/cc @nodejs/http @nodejs/http2