True, I too have never seen a WebSocket
True, I too have never seen a WebSocket connection stay up for 7 days--1 day is rare, but in my thinking, WebSocket "events" are not like a Request/Response cycle of HTTP. Each message is one-way and you would never be waiting on an external fetch. A WebSocket upgrade cycle could take longer and involve an external fetch but I don't think of that as an event. That's the only part of WebSockets that involes a traditional HTTP Request/Response.
Some clarity on this would be nice, but I have to say that I have never knowingly had a WebSocket "event" hang on me so I'm not even sure why this setting is in there. Someone must have experienced hangups at some point, is my best guess.
1 Reply
If memory serves correctly (and unfortunately memory is the only thing I can refer to at this point), we added this back when the Workers platform did upgrades once a week (hence the 7 days). The initial worry was that someone would accidentally busy loop their DO somehow, and prevent hibernation from happening (thereby driving up a huge bill). The only thing that would prevent it at the time would've been the once a week runtime upgrade. (I'm not sure about that previous point because we do have other timeouts and stuff, but this was many years ago now and the code has changed so much).
It was always just a last line of defence thing that we figured might be worth adding. I'm not sure anyone has ever actually used it before, and I forgot it even existed until I saw mention of it here today.
But nope, it was there from the start.
Edit: It seems we had planned to support it early but it didn't merge for quite a while: https://github.com/cloudflare/workerd/pull/628
Someone must have experienced hangups at some point, is my best guess.Good guess!
GitHub
Enable event timeout for hibernatable web sockets by jqmmes · Pull...
This PR adds new methods for setting event timeouts for hibernatable websockets.
When a timeout is, it defines the maximum amount of time that a single event of any type is allowed to run before th...