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

Node sockets timeout after 2 minutes by default #4468

Open
thsmale opened this issue Oct 20, 2023 · 1 comment
Open

Node sockets timeout after 2 minutes by default #4468

thsmale opened this issue Oct 20, 2023 · 1 comment
Labels
documentation Non-code related changes

Comments

@thsmale
Copy link

thsmale commented Oct 20, 2023

Context

  • node version: node14/18
  • module version: hapi16/20

What are you trying to achieve or the steps to reproduce ?

This sever uses the default implementation of route.options.timeout.socket which states node sockets will timeout after 2 minutes. However, the route handler has a 3 minute timeout, but the socket never hangs up after 2 minutes as expected.

'use strict';
 
const Hapi = require('@hapi/hapi');
 
const init = async () => {
 
  const server = Hapi.server({
    port: 4545,
    host: 'localhost'
  });
 
  /**
   * expecting default behavior that node socket hangs up after 2 minutes
   * however this timer exceeds 2 minutes then response is returned to user
   */
  server.route({
    method: 'GET',
    path: '/default-socket-timeout',
    handler: async (request, h) => {
      const timeout = delay => new Promise(resolve => setTimeout(resolve, delay));
      await timeout(180 * 1000);
      return 'timer is done';
    }
  });
 
  await server.start();
  console.log('Server running on %s', server.info.uri);
};
 
process.on('unhandledRejection', (err) => {
  console.log(err);
  process.exit(1);
});
 
init();
@thsmale thsmale added the documentation Non-code related changes label Oct 20, 2023
@kanongil
Copy link
Contributor

This sounds like a documentation issue.

The node default timeout for http server.timeout was changed in v13.0.0 to never timeout, according to the history entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Non-code related changes
Projects
None yet
Development

No branches or pull requests

2 participants