Receiving Socket Hang Up error often

Hello, I’m getting the following error message quite frequently:

FetchError: request to https://db.fauna.com/ failed, reason: socket hang up

I’m calling Fauna from an EC2 using the Fauna NPM package and have been creating a new Fauna client each time before making a request to Fauna.

There seems to be no pattern to the error. It seems to happen when I try to create a handful of writes within quick succession e.g. maybe 30 writes within 10 seconds of each other, but only occasionally – not every time. I don’t think this has anything to do with the known issue of Lambda thawing, as requests to Fauna are being made from a server.

Does anyone know what’s going on here?

Hi @robertsamarji We are not aware of any issue which could this. Can you please share the code of how you are creating the Fauna Client?

Hi @Jay-Fauna, thank you for replying, and sure. This is the code:

const faunadb = require('faunadb')
const q = faunadb.query
const { Create, Collection } = q

const Fauna = {}
const serverClient = new faunadb.Client({ secret: process.env.FAUNA_KEY_SECRET })

Fauna.createEntry = async (entry) => {
  try {
    await serverClient.query(
      Create(
        Collection('entries'),
        { data: entry }
      )
    )
  } catch (e) {
    console.log('createEntry error', e)
  }
}

Previously, I also created the serverClient variable inside the createEntry function. In both cases I am receiving a socket hang up error on occasion and the odd timeout error.

My environment is:

AWS EC2
App kept up with PM2
Node 8.9.4
faunadb ^3.0.1