brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
688 stars 31 forks source link

Endless loading due to MongoDB ObjectID #101

Closed kevincrossgrove closed 8 months ago

kevincrossgrove commented 8 months ago

Was getting an endless loading state in vike-react vike-react-query when using telefunc with MongoDB.

Here is an example

export default async function getEvent(eventCode: string) {
  const client = new MongoClient(process.env.MONGODB_CONNECTION_STRING || "");
  const db = client.db(process.env.MONGODB_DATABASE_NAME);

  const eventsDB = db.collection("Events");

  const event = await eventsDB.findOne<any>({
    Code: eventCode,
  });

  return event;
}

It can easily be fixed by converting the _id property from an objectID to a string, or delete the _id, filing because there was no error messages

brillout commented 8 months ago

Can you publish a reproduction? That'd be the best. I'll re-open then.