Skip to content

Wait for the polling loop to fault instead of sleeping in exception tests - #74

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-02u3c5
Sep 29, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/project-thread-02u3c5

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Before: RethrowExceptionsThrowsException failed on the macOS runner with "expected InvalidOperationException but none was thrown". The test slept 30 ms, then called RethrowExceptions(). On a slow runner the polling loop had not faulted yet, so there was nothing to throw.

After: the four tests that expect the action's exception (RethrowExceptionsThrowsException, RethrowExceptionsKeepsTheActionStackTrace, RestartResumesPollingAfterActionThrows, RestartDoesNotRethrowTheStaleActionException) wait on PollingTask itself. A 10 second timeout makes a hang fail the test. The assertions are unchanged.

How: the exception reaches PollingTask in three steps. First, a tick starts the action on the thread pool. Second, the action throws. Third, a later tick (at least one 10 ms polling interval later) sees the faulted ActionTask and throws out of the loop, which faults PollingTask. That takes one polling interval plus two thread pool dispatches, and no fixed sleep can guarantee that fits. The new WaitForPollingToFaultAsync helper awaits the task directly, so the wait is exact. The library is unchanged: surfacing the fault on the next tick is how it is designed to work, not a capture race.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RTMFFSY8FY5CpAhf6ikNH1


Generated by Claude Code

…ests

RethrowExceptionsThrowsException slept 30 ms and then expected the
action's exception. The exception only reaches PollingTask after three
hops: a tick starts the action on the thread pool, the action throws,
and a later tick (at least one 10 ms polling interval on) sees the
faulted task and throws out of the loop. A slow macOS runner took longer
than 30 ms, so RethrowExceptions found nothing to throw.

The four tests that expect a fault now await PollingTask itself, with a
10 second timeout that fails the test rather than hanging. The
assertions are unchanged. The library is not changed: capturing the
fault on the next tick is its documented behaviour, not a race.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RTMFFSY8FY5CpAhf6ikNH1
@sonarqubecloud

Copy link
Copy Markdown

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