Elm 0.19.1 port subscription cleanup – should the runtime handle it automatically?
0 reputation · 30 May 2026, 18:13 UTC
Port subscription lifecycle in Elm 0.19.1
The goal is to decide whether the Elm runtime should automatically unsubscribe JavaScript ports when a component that created the subscription is removed from the DOM, thereby preventing memory leaks that currently require manual tracking.
Constraints include maintaining backward compatibility with existing code that may rely on manual subscription management, avoiding unnecessary runtime overhead for applications that do not use ports, and ensuring deterministic behavior across different JavaScript environments.
- What is the current guarantee, if any, that port subscriptions are reclaimed when their owning component is torn down?
- What are the trade‑offs of introducing automatic port cleanup in terms of performance, compatibility, and developer ergonomics?
- How would automatic cleanup affect existing patterns where developers intentionally keep ports alive beyond a component’s lifetime?