How can I increase the default fetch/undici connection timeout so that it can be more than 10 seconds?

I’m getting this error when making an external API request with fetch. I’ve already tried several ways to increase the timeout, such as using AbortSignal, but the same issue still occurs, the fetch request fails after 10 seconds.

I don’t think this is a Fly issue. Show all your attempts to increase the timeout. I think there’s an option w/ fetch.

1 Like

May we see your code?

1 Like

Thanks for the response, everyone. I found the solution, I just needed to use fetch from undici instead of the built-in Node.js fetch.

Here’s what I did:

  • Installed undici@7.14.0
  • Used Agent dispatcher to set the timeout

I don’t think you need to install undici, nodejs uses it under the hood.

Yes, but the agent dispatcher isn’t there. It might be present, but the type definition isn’t.