Stuff never gets cleaned up for workers #6831
Documents clean up their WebSockets, EventSource, and timers as part of the "unloading document cleanup steps".
Workers only clean up their timers, at the end of run a worker after their event loop has shut down.
So per spec I believe the server is never told about a WebSocket connection disappearing if that connection is initiated by a worker. Is that what people implement?
What about EventSource? That seems like less of an issue since it just relies on termininating a fetch algorithm, and in general we probably want to terminate a lot of fetch algorithms (which is not well-specified now).
I think it would be nice to introduce "global object cleanup steps" which specs like WebTransport could use for the purposes discussed there, and maybe we could move WebSocket/EventSource/timer cleanup there. That way they don't need to separately hook into window/shared worker/service worker/dedicated worker cleanup locations.
But the details might be tricky, e.g. documents deal with bfcache and the salveagable state in a special way (/cc @rakina @fergal), and we probably want spec authors to think through that interaction in some detail. Similarly shared/service workers might have different considerations than dedicated workers. So I'm not sure.
The text was updated successfully, but these errors were encountered:
I think having a "global object cleanup steps" makes sense, we can just pass whether this is for the owner going away permanently or not (the document is salvageable), and maybe "is this the only owner?" for shared workers?
I guess it is a bit awkward to have both that and independent specifications listening to "salvageability changes" as recommended in w3ctag/design-principles#317, but maybe we can just call that out in a comment there too.
(btw @fergald is the BFCache Fergal :) )