What is the Workers timeout?
Got a request to implement the IDLE command into my CF Workers IMAP lib. That would mean keeping the TCP connection alive for longer periods of time.
From what I understand Cloudflare bills based on CPU time, rather than the total time it took for the Worker to finish, so in terms of billing it shouldn't be sky high.
The problem is that it is definitely not the use case for a Worker (well, the exact opposite really). Theoretically, though, after what time would the worker process be terminated?
9 Replies
Essentially, how long can a Worker idle connected to a TCP socket?
I imagine like a minute or so is fine, right?
Ah, wait, finally managed to find the limits.
Theoretically infinite, however a few times a week the runtime is updated.
The client has to stay connected
When the client disconnects, all tasks associated with that client request are canceled. Use event.waitUntil() to delay cancellation for another 30 seconds or until the promise passed to waitUntil() completes.
Yeah I just thought of that
What about cron triggers?
Scheduled Workers (Cron Triggers) have different limits on CPU time based on the schedule interval. When the schedule interval is less than 1 hour, a Scheduled Worker may run for up to 30 seconds. When the schedule interval is more than 1 hour, a scheduled Worker may run for up to 15 minutes.
All right, thank you!
that's kind of conflating cpu time and duration there but I believe they're the same for that aspect. Docs only explicitly state 15 mins for cron though
def not build for superr long lived connections eitherway
yeahh, def not
I mean it is kiiinda possible, just not practical in any way