Faunadb request not completing before returning data

my faunadb request isnt fully completing before returning the data, it seems capped at 63 completed data requests. maybe a time limit on functions? basically, I am fetching all the guests that have registered for my wedding, fine for weeks, now it has reached 63 it fails to get the rest of the guest responses which I can see in my faunadb dashboard., but returns with a response of 200 and all guests up till that point.

here’s the function code

require("dotenv").config();
const faunadb = require("faunadb");
const q = faunadb.query;

exports.handler = async (req, context) => {
  const client = new faunadb.Client({
    secret: process.env.SECRET,
  });
  try {
    const res = await client.query(
      q.Map(
        q.Paginate(q.Match(q.Index("guests"))),
        q.Lambda((x) => q.Get(x))
      )
    );
    const data = res.data.map((i) => i.data);
    console.log(data);
    return {
      statusCode: 200,
      body: JSON.stringify(data),
    };
  } catch (err) {
    console.log(err);
    return {
      statusCode: 400,
    };
  }
};

I’m not aware of any 63 request limit. I’ve crossed a 1000 and it still works fine. I get my response within 2 seconds in most cases. Here’s how I do it:

const faunaDB = require('faunadb')
const dbName = new faunaDB.Client({
  secret: process.env.FAUNADB
})

exports.handler = async () => {
  return dbName.query(faunaDB.query.Paginate(faunaDB.query.Match(faunaDB.query.Index(indexName)))).then(indexedData => {
    return {
      statusCode: 200,
      body: JSON.stringify(indexedData.data),
      headers: {
        'cache-control': 'public, max-age=0, must-revalidate'
      }
    }
  }
}

Does this work for you?

1 Like