fix(timer): make tag debounce actually reject stale ticks#1012
Open
momomuchu wants to merge 1 commit into
Open
fix(timer): make tag debounce actually reject stale ticks#1012momomuchu wants to merge 1 commit into
momomuchu wants to merge 1 commit into
Conversation
tag was added in 730f5a2 alongside stopwatch's identical mechanism, but timer never increments it, so the guard in Update never rejects anything. A duplicate Start/Toggle on an already-running timer spawns a second tick stream that runs forever, permanently doubling the countdown speed. Increment tag on each accepted tick, mirroring stopwatch, so the stale stream gets rejected after the first race. Fixes charmbracelet#1007
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
timer/timer.go copied the tag field from stopwatch (730f5a2) but never incremented it, so the debounce guard in Update never rejects anything. A duplicate Start/Toggle on an already-running timer spawns a second tick stream that runs forever, permanently doubling the countdown speed.
This increments tag on each accepted tick, same as stopwatch already does, so the stale stream gets rejected after the first unavoidable race.
Note: #867/#922 also touch this symptom via a different mechanism (guarding Update/startStop on running-state equality). This PR doesn't touch that path or compete with it, it's scoped to #1007, which asks why tag is dead code. The answer is it's supposed to do exactly this and was just never wired up, so finishing it seemed better than deleting it.
Fixes #1007