Skip to content

fix(scheduler): correct spacedDelay unit mismatch with withNoOverlaps() + aligned start time - #693

Merged
lmajano merged 1 commit into
developmentfrom
claude/coldbox-scheduled-task-period-p24bcl
Sep 2, 2026
Merged

fix(scheduler): correct spacedDelay unit mismatch with withNoOverlaps() + aligned start time#693
lmajano merged 1 commit into
developmentfrom
claude/coldbox-scheduled-task-period-p24bcl

Conversation

@lmajano

@lmajano lmajano commented Sep 2, 2026

Copy link
Copy Markdown
Member

Description

ScheduledTask tasks combining .withNoOverlaps() with a daily start-time window (.between() / .startOnTime()) were re-firing far more frequently than configured — e.g. every( 1, "minutes" ).between( "07:00", "18:00" ).withNoOverlaps() fired roughly every 1 second instead of every 60 seconds.

Root cause: in ScheduledTask.cfc start(), the noOverlaps -> spacedDelay snapshot (spacedDelay = period) ran before calculateStartTimeAlignedDelay() converted period/timeUnit into seconds. spacedDelay was left holding the value in its original unit (e.g. 1 for "1 minute") while timeUnit had already changed to "seconds". ScheduledExecutor.scheduleWithFixedDelay() applies a single timeUnit to both delay and spacedDelay, so the JDK scheduled a 1-second repeat instead of 60.

Fix: move the noOverlaps -> spacedDelay snapshot to after the start-time alignment call, so it always derives from the already-converted period/timeUnit. Tasks with no startTime (which never hit the alignment/conversion path) are unaffected.

Jira Issues

Type of change

  • Bug Fix
  • Improvement
  • New Feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project (cfformat)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes — could not run the full suite (no CommandBox/engine available in this sandbox); logic verified by manual trace against the reported repro, please confirm on CI

🤖 Generated with Claude Code

https://claude.ai/code/session_013HqnErWoJMwuTHANY4gaL1


Generated by Claude Code

…() + aligned start time

withNoOverlaps() snapshotted spacedDelay from period before the start-time
alignment (between()/startOnTime()) converted period/timeUnit to seconds,
leaving spacedDelay in the original unit while timeUnit had already
changed. scheduleWithFixedDelay() then applied the new seconds-based
timeUnit to the stale spacedDelay value, causing tasks like
every(1,"minutes").between(...).withNoOverlaps() to re-fire every second
instead of every 60 seconds.

Moves the noOverlaps -> spacedDelay snapshot to after start-time alignment
so it always reads the already-converted period/timeUnit.

Fixes COLDBOX-1434

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HqnErWoJMwuTHANY4gaL1
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit e100605. ± Comparison against base commit d72cca3.

♻️ This comment has been updated with latest results.

@lmajano
lmajano merged commit ad82ee5 into development Sep 2, 2026
28 checks passed
@lmajano
lmajano deleted the claude/coldbox-scheduled-task-period-p24bcl branch September 2, 2026 19:46
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.

2 participants