4

After lengthy investigations the problems seems to be that the long running request times out and the endpoint is called again in NodeJS. There is no new network request from browser. I made a few tests and after 2 mins the endpoint is invoked again. I read that the default timeout for the http requests in NodeJS in 2mins.

https://nodejs.org/docs/latest-v12.x/api/http.html#http_server_timeout

I am using NestJS (with express), does anyone know how to increase this timeout value using NestJS framework ?

Here is my initial question: Angular 9 http call with nestjs backend

-Jani

Logica
  • 977
  • 4
  • 16
jani_r
  • 637
  • 1
  • 7
  • 18

2 Answers2

1

You can use some packages to apply a timeout as a middleware. https://www.npmjs.com/package/@nest-middlewares/connect-timeout

This package is just a wrapper of an express middleware, so be sure you use the express platform on your project.

0

this seems to do the trick per request. I don't know how to do it on server level but this is enough for me.

req.setTimeout(300000); // 5 minutes
jani_r
  • 637
  • 1
  • 7
  • 18
  • I tried that and it does not work. My problem is that I need to increase the default server timeout (or request timeout) and that package does not modify that. See here: https://stackoverflow.com/questions/55364401/express-js-connect-timeout-vs-server-timeout. My answer fixes the issue per that specific request. – jani_r Apr 12 '20 at 07:50