Request aborted due to timeout Nodejs Fauna v4

Hi, I am testing locally a project that uses faunadb v4.8.0 on Nodejs v18 and all my requests return the error “Request aborted due to timeout”. The client I use is set like this

const client = new faunadb.Client({
  secret: process.env.FAUNADB_SERVER_SECRET,
  domain: "db.eu.fauna.com",
  scheme: "http",
  timeout: 3,
})

I tried with different timeouts and without that parameter but the result is the same. Maybe some of the queries are supposed to get empty responses, but in that case it should not timeout. Is there something I can look for to solve that problem? Upgrading to v10 is not an option for the moment, and downgrading nodejs is also not possible.

Thank you!

Hi @daniel and welcome! :wave:

It is reasonable for some queries to take a long time (e.g. even a minute or more) if you are requesting a lot of work to be done. The 503 “Request aborted due to timeout” error is due to Fauna spending too long working on your query.

Please note the different settings that the driver provides: GitHub - fauna/faunadb-js: Javascript driver for FaunaDB v4

The page has this to say about the timeout setting on the client

The first option (i.e. timeout) represents a HTTP timeout on the client side. Defined in seconds, the client will wait the specified period before timing out if it has yet to receive a response.

I want to highlight that this is the client-side timeout. Setting this higher will not increase the default time that Fauna will spend working on your query.

On the other hand, using the client’s queryTimeout dictates how long FaunaDB will process the request on the server before timing out if it hasn’t finished running the operation.

You may be looking for the queryTimeout setting instead. It is recommended to always set the client timeout at least a few seconds longer than the query timeout.

Note about v10

In the v10 drivers, we have update the logic so you configure a client timeout buffer. With this, the client-side timeout is always greater than or equal to the query timeout.

// In this configuration, Fauna will execute your query for up to 60s,
// and the client will cancel the request after 70s
const client = new Client({
  secret: FAUNA_SECRET,
  query_timeout_ms: 60_000,
  client_timeout_buffer_ms: 10_000
});

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.