Skip to content

Sleep until a task timer is due before waking it - #3

Merged
PytechNo merged 1 commit into
mainfrom
fix-task-wait-early-wake
Oct 16, 2026
Merged

PytechNo merged 1 commit into
mainfrom
fix-task-wait-early-wake

Conversation

@PytechNo

Copy link
Copy Markdown
Owner

Summary

Main's first Tests run failed on luau task library > orders spawn, defer, delay, and wait like Roblox: task.wait(0.03) returned slightly less than 0.03.

The Luau task scheduler (LUAU_TASK_BOOTSTRAP in src/workers/projectRuntime.ts) slept once with setTimeout, then resumed the earliest timer without checking the clock again. Host timers can fire about a millisecond early, so the task woke before its wake time. The scheduler now sleeps again until the wake time has passed, so task.wait always returns at least the time requested, as on Roblox.

Test plan

  • npm test passes locally (456 tests)
  • The task library tests pass on 5 more local runs
  • The Tests check passes on this PR

🤖 Generated with Claude Code

The Luau task scheduler slept once with setTimeout and then resumed the
earliest timer without checking the clock. Host timers can fire about a
millisecond early, so task.wait(0.03) could return 0.0299, which failed
the task library test on main's first CI run. The scheduler now sleeps
again until the timer's wake time has passed, so task.wait always
returns at least the time requested, as on Roblox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PytechNo
PytechNo merged commit bee91f5 into main Oct 16, 2026
2 checks passed
@PytechNo
PytechNo deleted the fix-task-wait-early-wake branch October 16, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant