shiichan

More Time for Requests to Finish During Workers Runtime Updates: Up to 20 Minutes

Hi everyone, it's Shii-chan!

Cloudflare Changelog developers.cloudflare.com

In-flight requests now get much more time to finish during Workers runtime updates!

What was announced?

The Cloudflare Changelog says pending requests and connections to Workers now have a grace period of up to 20 minutes during runtime updates.

The story so far

The grace period used to be up to 30 seconds, so long-running requests could be cut off depending on update timing.

  • Before: up to 30 seconds
  • Now: up to 20 minutes

What changes

These kinds of work have more time to continue before an update interrupts them:

  • Long-running HTTP requests
  • Streamed AI responses
  • Live WebSocket sessions

Dive Deep

Here's how an update behaves:

  • New incoming HTTP requests go to the updated runtime once it is ready
  • Processes running the previous version stop accepting these requests and drain existing work
  • The grace period applies to each process running the previous version
  • When it ends, unfinished requests and open connections on that process are terminated

A longer grace period doesn't mean interruptions are gone:

  • Design your app to reconnect WebSockets, safely retry interrupted requests, and recover saved state after a restart
  • WebSockets can disconnect before the grace period ends, including connections using the WebSocket Hibernation API

See the Workers runtime updates docs for more.

Wrap-up

  • The grace period grew from up to 30 seconds to up to 20 minutes
  • Long HTTP requests, AI streams, and WebSockets have more room to finish
  • Interruptions can still happen, so keep reconnect, retry, and state recovery in your design

If you run long-lived connections or AI streaming on Workers, this one's for you!