A cancelled drain gets forgotten, so a re-run of the hook's effect arms a fresh one. That one sentence is the whole fix, and it took two separate fields to make it true.
In liveregion, our open-source accessibility helper, the timer that drains the announcement queue lives in the Driver class in src/driver.ts. Screen-reader announcements need to stay visible long enough to be read, then get cleared, then get replaced by the next one. That is a timer, and a timer is state you can get wrong in more ways than it looks.
The mistake we were walking toward: one boolean. "Is a drain running?" doing double duty as "are drains allowed?" It reads fine until React runs the same effect twice, or a strict-mode remount fires cleanup and setup back to back. Then "cancelled" and "shut down" are indistinguishable, and you either lose the queue or leak a stale handle.
So the class keeps them apart. A private #timer field holds the pending setTimeout handle. A separate #stopped field records whether drains may be armed at all. The private #cancel clears the timeout and sets #timer back to null, so no stale handle survives a cancellation, but it says nothing about the future. stop calls #cancel and sets #stopped to true. start sets #stopped to false and calls #pump. clear empties the queue, calls #cancel, then repaints.
The part worth copying is #pump, which refuses in three ordered checks before it arms anything:
First, it returns right away while #stopped is true.
Second, it returns when the queue has no current message, since a drain with nothing to clear would fire against the next real message and cut it short.
Third, it returns when #timer is not null. Re-arming on every announce would hold one message on screen while the queue starves behind it.
Only past all three does it arm a setTimeout for the queue's clearAfterMs, which nulls #timer, advances, repaints, and pumps again.
The payoff shows up in src/useAnnouncer.ts: the effect body calls driver.start() and the cleanup calls driver.stop(), not clear(). announce still queues and repaints while stopped, so anything arriving mid-teardown is kept. A duplicate effect run resumes the flow instead of throwing it away.
The general rule we keep re-learning across payment retries, notification fan-out, and collections automation: cleanup and teardown are different operations. Cleanup releases a resource. Teardown revokes permission to acquire it again. When one flag means both, idempotent re-entry stops being idempotent, and in UI that looks like a flaky test, while in a payment path it looks like a double send.
Worth checking where "stop" in your own code quietly also means "discard".