Ramonda

interval-with-no-cleanup

This fails the run. Where it is wrong about your code, // ramonda-check-ignore <reason> on the line says so, and the reason is printed on every run.

Reported when a component starts a raw setInterval whose id nothing ever clears, so it keeps firing after unmount.

The framework reports the same fault while running, as RMD006 — but only once the line actually runs. This is the same fault proved from the source instead.

An interval does not stop by itself, and nothing about unmounting a component touches one. So the callback keeps running on a schedule, reading state nobody is showing and holding the component and everything it closed over alive. Open and close the same view ten times and there are ten of them.

@interval(1000) tick() { … } starts on mount and clears itself on unmount, which is what it is for. For an interval the APP starts — on a click, after a fetch — the Interval hook does the same for one it does not own the start of:

private ticker = this.use(Interval, () => ({ run: this.refresh })); begin() { this.ticker.start(1000); } halt() { this.ticker.stop(); }

A raw timer is still allowed, and then the id has to live on a class property so @destroyed can reach it:

@destroyed stop() { clearInterval(this.tick); }

A returned closure cannot do this — nothing calls it — which is why the fallback is a property rather than a cleanup function.

setTimeout is NOT reported: it stops on its own, and telling a long one from a short one is a judgement about a number. The framework catches those at runtime, where it can see what is still armed.

Next