faunadb-js icon indicating copy to clipboard operation
faunadb-js copied to clipboard

queryTimeout is broken

Open dferber90 opened this issue 4 years ago • 0 comments

When using the queryTimeout option, the promise returned by faunaClient.query(xxx, { queryTimeout: 30 }) never resolves.

This was my code in a Cloudflare Worker. The promise would simply never resolve.

const projectRef = q.Ref(q.Collection("Projects"), options.projectId);
await faunaClient
    .query<string | null>(
      q.If(
        q.Exists(projectRef),
        q.Select(["data", "flagsRevision"], q.Get(projectRef)),
        null
      ),
      { queryTimeout: 10 }
    )
    .catch((error) => {
      console.error("fauna error");
      console.error(error);
      return null;
    })

As a workaround, I used the signal option instead of the queryTimeout.

dferber90 avatar Jan 16 '22 16:01 dferber90