nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
6.06k stars 529 forks source link

how to set a timeout for long running queries? #1919

Open pcace opened 1 year ago

pcace commented 1 year ago

Hi,

i am having trouble finding a way to keep fetch running when i have to deal with long running queries. i am talking about a minute max time. the query works fine in the browser, and returns 200. undici seems to be waiting exactly 30s till it fails.

this is how my request init looks like: {"method":"GET","headers":{},"keepalive":true,"keepAliveInitialDelay":120000, "socketTimeout":0} i am using undici 5.18.0. installed via npm.

Any idea how to solve that?

Cheers and Thanks!!

metcoder95 commented 1 year ago

Have you tried with bodyTimeout and headerTimeout? Ref - https://undici.nodejs.org/#/docs/api/Dispatcher?id=parameter-dispatchoptions

If the connection was properly established, keep alive won't have an effect as the request is waiting for a response or further ACK to continue with the connection alived