I’ve built a light-weight queue management service using Google Firestore and Netlify’s serverless functions.
There’s a function called “queue_next.js” that checks whether we can place the next order, and if we can, it places an order. The last step should be calling itself so the queue continues to be processed. That last step – calling itself via Axios – is called asynchronously, but not using
await so the current function can return and just spawn itself again.
When developing locally it’s working like a charm: an order gets placed, the queue processes the next job up, and calls itself at the last second right before returning the previous result. No timeout, no problem.
When deployed on Netlify in production, however, it’s very inconsistent. Sometime the recursive call makes it’s way through once or more times, sometimes it just stalls completely. There’s nothing in my logs that shows any issues and I’m struggling to figure it out.
Here’s a snippet of the code:
I’m wondering if – because I’m not suings
await – that in some cases the function returns before that last moment call is sent, but I have no way of testing.
Any leads would be super helpful.