Spot the bug in ticker cleanup

from Memory management
Node 24 intermediate 4 min 1 issue to find

Find why stopping this ticker does not release every registration created by mountTicker.

JavaScript
function mountTicker(feed) {
  const history = [];
  feed.addEventListener('price', (event) => {
    history.push(event.value);
  });
  const timerId = setInterval(() => feed.refresh(), 1000);

  return {
    history,
    stop() {
      clearInterval(timerId);
    },
  };
}
Open in playground
Report an error