I have a function that loops through documents to check to check their expiredDate . It results to error when I run the function triggered by a cron job.
An internal curl error has occurred within the executor! Error Number: 104. Error Msg: Connection reset by peer\nError Code: 500
It runs fine when I remove the while loop. Here's the code
while (products.total > 0) {
for (const product of products.documents) {
if (new Date(product.expiryDate) < new Date()) {
await db.createDocument("drug-inventory", "notification", ID.unique(), {
type: "expired-drug",
isAdmin: false,
product: product.$id,
expiredDate: product.expiryDate,
});
}
}
offset += 50;
products = await db.listDocuments("drug-inventory", "products", [
Query.limit(50),
Query.offset(offset),
]);
}
How long does it run before this happens?
1 - 3 seconds
And it happens every time?
yes, everytime
Recommended threads
- [v1.8.1] Getting error "(role: applicati...
... but that scope doesn't exist. I am trying to get a function to run and modify tables in the database dynamically. I set everything up and eventually got: ...
- Scheduled function silently stopped firi...
Function is scheduled `* * * * *` and is `enabled: true`, but Appwrite Cloud has stopped queueing executions. Last execution: **2026-05-30 00:47 UTC** (~46h...
- Unable to create Sites or Functions with...
Heya, I was looking at the appwrite documentation for Sites API with the server api: https://appwrite.io/docs/references/cloud/server-nodejs/sites I can’t fin...