Files
iptvnator/apps
4grayandClaude Opus 4.7 2b3c65932d fix(data-service): track and actually remove window message listeners
Both ElectronService.listenOn() and PwaService.listenOn() called
window.addEventListener('message', callback) but neither could remove
the listener afterwards:

- ElectronService.removeAllListeners() called a placeholder
  getListenerForCommand() that returned a fresh () => undefined function
  on every invocation — never matching the registered listener (with a
  comment confessing as much).
- PwaService.removeAllListeners() was a literal `// not implemented`
  no-op.

The result was a latent memory leak: every listenOn() call accumulated
a global window listener that nothing could remove. Calling listenOn()
twice for the same command also stacked duplicate listeners.

Track callbacks in a messageListeners Map keyed by command name. On
listenOn(), drop any existing listener for that command before adding
the new one. On removeAllListeners(type), remove either the named
listener or all of them (when type === 'all').

The fix lands proactively: grep finds no current callers in the
renderer, so today's leak is theoretical. But the API is exposed via
the abstract DataService and the placeholder comment explicitly invited
the bug. Closing the footgun is cheaper than discovering it later.

Inspired by matracey/iptvnator@df7e1dc — extends the fix to PwaService,
which had the same bug in even more obvious form.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 3f453cc0085a
2026-05-02 00:29:49 +02:00
..
2026-04-29 00:20:34 +02:00
2026-04-27 00:24:23 +02:00