fix: cancel orphaned finish scheduler when a second break starts#1803
Open
vyguera wants to merge 2 commits into
Open
fix: cancel orphaned finish scheduler when a second break starts#1803vyguera wants to merge 2 commits into
vyguera wants to merge 2 commits into
Conversation
added 2 commits
June 17, 2026 10:11
When two breaks start in quick succession (e.g. via concurrent CLI calls), the breakStarted handler replaces this.scheduler without cancelling the previous finishMicrobreak timer. That orphaned timer fires after the screen locks and both breaks are force-closed, calling finishMicrobreak/finishBreak against a null windowArray. Cancel the previous scheduler in both microbreakStarted and breakStarted before creating the new one. Also add a null guard in closeWindows as a defensive fallback. Fixes hovancik#1802
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.
When two breaks start in quick succession via concurrent CLI calls, the
breakStartedhandler assigns a newSchedulertothis.schedulerwithout cancelling the existingfinishMicrobreaktimer. That timer keeps running independently. If the screen locks before it fires, both breaks are force-closed andmicrobreakWinsis set tonull. When the orphaned timer fires shortly after, it callsfinishMicrobreakagainstnulland throws.The fix cancels the previous scheduler in both
microbreakStartedandbreakStartedbefore creating the new one. A null guard incloseWindowsis included as a defensive fallback.Tests in
test/breaksPlanner.jsverify that emittingbreakStartedwhile afinishMicrobreaktimer is running cancels the orphaned timer, and vice versa.To reproduce: run
stretchly longandstretchly miniwithin a second of each other, then lock the screen while both overlays are active and keep it locked for at least the Mini break duration. Fixes #1802.