API Timeout Node JS

Hi everyone, I have an API that runs a rather complex query that takes a couple of minutes to complete.
I noticed that I receive an error message due to the request timeout, is it possible to increase the timeout value?

you can put it in a bull queue (see extension from @tbvgl ) I think that’ll help

Hi Karh, unfortunately I don’t need to start a task in parallel but increase the waiting time to receive a result from the connect server.
At the moment it seems to me that after about 30sec the connect server gives me an error while I have a procedure that takes about 2 minutes

As a general practice, you should not have any script in foreground working for that long.
Such long-tasks should be processed in the background.

Bull queue suggested by karh, is not only used for parallel processing, but primarily for background processing. You can set queue options to limiter with 1 to run one process at a time.

I am not sure sure how to increate the timeout time on local machine, but on servers, there is usually nginx involved as a proxy server. In nginx, you can set an increased timeout value so that client can keep waiting for a response for longer period of time.

To add to Sid: you can set a delay in the bull job of 2 minutes so every job you add to the queue will be started after 2 mins

Hi Karh, I’m trying to use the library you suggested but despite having followed the installation instructions I can’t seem to find it.

1

Check if your package.json has bull package defined.
Else, just run npm i bull in terminal, and then try again.