KEMBAR78
Stuff never gets cleaned up for workers · Issue #6831 · whatwg/html · GitHub
Skip to content

Stuff never gets cleaned up for workers #6831

@domenic

Description

@domenic

Spotted by @yutakahirano in w3c/webtransport#127 (comment)

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions