Fix stale delayTimeout execution after Stop#5827
Merged
walterbender merged 1 commit intosugarlabs:masterfrom Mar 8, 2026
Merged
Fix stale delayTimeout execution after Stop#5827walterbender merged 1 commit intosugarlabs:masterfrom
walterbender merged 1 commit intosugarlabs:masterfrom
Conversation
Signed-off-by: Ady0333 <adityashinde1525@gmail.com>
Contributor
Author
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
vanshika2720
approved these changes
Feb 20, 2026
Contributor
vanshika2720
left a comment
There was a problem hiding this comment.
LGTM @walterbender please review
parthdagia05
pushed a commit
to parthdagia05/musicblocks
that referenced
this pull request
Mar 15, 2026
Signed-off-by: Ady0333 <adityashinde1525@gmail.com>
parthdagia05
pushed a commit
to parthdagia05/musicblocks
that referenced
this pull request
Mar 15, 2026
Signed-off-by: Ady0333 <adityashinde1525@gmail.com>
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.
Summary
This PR fixes an issue where pending block execution timers created during Run Slowly mode were not cancelled when Stop was pressed. These stale delayTimeout timers could fire after stopping the program and execute blocks from the previous run into the next run’s execution lifecycle.
What changed
Added cleanup in doStopTurtles() to:
Why this change was needed
runFromBlock() schedules execution using setTimeout and stores the handle in turtle.delayTimeout. When Stop was pressed, doStopTurtles() set stopTurtle = true but never cleared these timers. As a result, delayed callbacks from the previous run could still fire after Stop and execute runFromBlockNow() without any stop guard.
This caused _alreadyRunning to be set during the next run, which made runLogoCommands() treat the run as a premature restart. The natural-end path then suppressed onStopTurtle(), leaving the Stop button stuck in the active state and Save/Record controls disabled even after execution finished.
Scope
Affects only run/stop lifecycle cleanup in doStopTurtles().
No changes to block execution logic or scheduling behavior.
Verification
Enabled Run Slowly mode and ran a multi-block program.
Pressed Stop mid-execution and immediately pressed Play again.
Verified that execution completes normally and the Stop button resets.
Confirmed Save and Record buttons re-enable after run completion.
Impact
Prevents stale execution from leaking into the next run.
Ensures correct lifecycle termination after Stop → Play.
Restores proper UI state (Stop button, Save/Record) after execution.
No breaking changes.