dhatGuyOriginal post
Web Developer
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),
]);
}
Summary
A developer's function with a while loop checking for expired dates in documents triggers a curl error when run by a cron job. The error message is `An internal curl error has occurred within the executor! Error Number: 104. Error Msg: Connection reset by peer\nError Code: 500`. The loop runs smoothly without the while loop.