koajs / koa

Expressive middleware for node.js using ES2017 async functions

Home Page:https://koajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

server.requestTimeout didn't work

ching2018 opened this issue · comments

commented

Describe the bug

Node.js version:
v18.3.0

OS version:
ubuntu 22.04 arm64

Description:

After 5 minutes i received an error.
server.requestTimeout didn't work.

The http.server timeouts have changed in Node.js v18. The headersTimeout is set to 60000 milliseconds (60 seconds), and requestTimeout is set to 300000 milliseconds (5 minutes) by default. The headersTimeout is the time that is allowed for an HTTP request header to be parsed. The ```requestTimeout`` is the timeout used for an HTTP request.

Actual behavior

Expected behavior

Code to reproduce

      const app =  new Koa();
      let server = await app.listen(1234);
      server.requestTimeout = 100 * 60 * 1000;

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.

This isn't a Koa thing, it's node:http thing. Though I think this will only timeout if the request is not fully received within specified time from client. From docs:

Sets the timeout value in milliseconds for receiving the entire request from the client

import http from 'node:http'
import setTimout from 'node:timers/promises'

const server = http.createServer(async function (req, res) {
  await setTimeout(5000)
  res.writeHead(200, { 'Content-Type': 'text/plain' })
  res.end('OK')
})

server.requestTimeout = 30
server.listen(4000)

Closing due to invalid and stale issue