Skip to content

Reject a non-positive PollingInterval in Start - #60

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/intervalaction-53-validate-polling-interval
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/intervalaction-53-validate-polling-interval

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #53

What was wrong

IntervalAction.Start checked the options and the action for null but never checked PollingInterval, so a bad value only surfaced later inside the polling loop:

  • A negative interval ran the action once, after which Task.Delay threw and left PollingTask faulted, with nothing reporting it.
  • Timeout.InfiniteTimeSpan left Restart() and Stop() waiting on a delay that never ends.
  • Zero turned the loop into a busy spin.

Change

Start now throws ArgumentOutOfRangeException when PollingInterval <= TimeSpan.Zero. The check covers InfiniteTimeSpan, which is −1 ms. The exception is documented on Start.

I didn't include the optional cancellable delay from the issue. That change overlaps the restart logic that #55 is already changing for #52, so it is better done after #55 lands. This branch merges cleanly with #55.

Tests

  • StartNonPositivePollingIntervalThrows covers −2 s, 0 and InfiniteTimeSpan, as the acceptance criteria ask.
  • With the guard reverted, all three cases fail. With it applied, they pass.
  • The full suite passes locally, 17 of 17.

🤖 Generated with Claude Code

https://claude.ai/code/session_018fKEEvMM2dQpZfMjTCXhRL


Generated by Claude Code

Start never checked PollingInterval, so a bad value surfaced later inside
the polling loop: a negative interval faulted the loop after the first
run, Timeout.InfiniteTimeSpan left Restart() and Stop() waiting on a delay
that never ends, and zero spun a core. Start now throws
ArgumentOutOfRangeException for any interval that is not greater than
zero, where the value is supplied.

Fixes #53

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018fKEEvMM2dQpZfMjTCXhRL
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 09b7020 into main Sep 27, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/intervalaction-53-validate-polling-interval branch September 27, 2026 15:11
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.

Non-positive or infinite PollingInterval silently kills the loop or makes Restart()/Stop() hang forever

2 participants