JS Faunadb client v4.2.0 constantly timing out

Hi, I’ve been getting this error very frequently:

[TimeoutError: Request aborted due to timeout] {
  message: 'Request aborted due to timeout',
  isTimeoutError: true
}

after upgrading to JS faunadb client v4.2.0

this includes even simple queries like

const response = await client.query(
  q.Ref(q.Collection('Service'), serviceId)
);

Specs for reference:
Node: 12.16.1
Faunadb: 4.2.0
MacOS: 11.3

Interesting my other project which also connects to the same database but using JS faunadb client v3.0.1 does not encounter this sort of issues — all queries go through smoothly without timeouts.

I have also noticed another thread that might be related — Receiving Socket Hang Up error often
It seems that one of them is also on v4.x of js faunadb client

Any help on this would be greatly appreciated, thanks!

Update:
I have just downgraded my client to v3.0.2 and it works perfectly again, no more timeouts. I’m pretty sure the issue is isolated to v4.x of the client.

Hi Sid,

I’m going to pass this along to our driver developers so they can take a look and see if there’s room for improvement. You’re welcome to file issues with them directly in the future if something like this happens again. The place to report issues is available on the GitHub project for the driver.

Thanks,
Cory

1 Like

It’s really hard to distinguish as it uses different API versions.
have you measured response time? have you pass custom timeout option?
this error occurs if your request takes longer than timeout (by default 60 sec)

Thanks for passing it on to the devs @Cory_Fauna

@Sergii_Zinkevych — nope I didn’t measure the response time but I did not pass any custom timeout either; 60 secs timeout sounds about right actually.
I simply ran the script and waited for it to produce some form of result, or timeout (which happened most of the time with 4.2.0).

@Sid could you share the full code, please (without secret). this would help us as we weren’t able to reproduce

@Sergii_Zinkevych that’s weird, perhaps it has something to do with geographic location? I’m in Singapore if that information helps

Anw this was all I did

// test.js

const faunadb = require('faunadb');

async function test() {
  const FDB_TOKEN = 'token_here';
  const serviceId = '12345';

  const q = faunadb.query;
  const client = new faunadb.Client({ secret: FDB_TOKEN });
  
  try {
    const response = await client.query(
      q.Ref(q.Collection('Service'), serviceId)
    );

    console.log(JSON.stringify(response, null, 2));
  } catch (e) {
    console.log(e);
  }
}

test();

I don’t really understand why, but when I changed VPN to Singapore I got the same issue on and off.

Long story short, nodejs 12.16.1 doesn’t trigger end event for Http2Stream.
Here is an issue Request streams from http2 intermittantly not emitting end event · Issue #31309 · nodejs/node · GitHub

I would recommend updating NodeJS version. If you still need to use v12.x.x, install lts/erbium → v12.22.1

1 Like