Waiting in worker

Hey! Is there a way to wait/sleep in a worker without incurring costs for the waiting time? Basically a setTimeout, or something similar. I call an external service, and sometimes it's too quick. In 99.9% of the cases, the data is there 100-200ms after the first check. I have an extremely restricted frontend (very sandboxed), and I'm not allowed any client side code at all, so that's not an option. Using queues is also not an option.
2 Replies
Walshy
Walshy•7d ago
await new Promise((resolve) => setTimeout(resolve, 5_000)) workers don't bill on wall time, we bill on cpu time
Zn4rK
Zn4rKOP•7d ago
Thank you! I did it exactly like that, but got a bit worried that this would count towards cpu time for some reason 🙂

Did you find this page helpful?