Skip to content

Treat an out-of-range navigation timeout as no timeout instead of throwing after undo/redo [patch] - #107

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/undoredo-104-navigation-timeout
Sep 28, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/undoredo-104-navigation-timeout

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #104

What changed

NavigateSafelyAsync is meant never to throw, but it called CancellationTokenSource.CancelAfter outside its try. CancelAfter rejects negative delays other than −1 ms, and delays above its limit. So TimeSpan.MaxValue, which is a natural way to say "no timeout", made UndoAsync/RedoAsync/UndoToSaveBoundaryAsync throw ArgumentOutOfRangeException after the change had already been applied.

  • The linked token source is now created inside the try, so nothing in navigation can escape.
  • A timeout that is not positive, or that is longer than int.MaxValue ms, now means navigation runs with no timeout. int.MaxValue ms (about 24.8 days) is the limit CancelAfter accepts on the older targets this library builds for, such as netstandard2.0. The default 5 s timeout is unchanged.

Test

Added UndoRedoAsync_NavigationTimeoutOutsideCancelAfterRange_AppliesAndNavigatesWithoutThrowing, a data-driven test over TimeSpan.MaxValue, 60 days, −5 s and TimeSpan.MinValue. For each value it checks that undo and redo return true, that the value changes, and that navigation still runs.

  • Without the fix, all four cases fail with ArgumentOutOfRangeException (Parameter 'delay').
  • With the fix, all 98 tests pass on net10.0, and the library builds for every target.

🤖 Generated with Claude Code

https://claude.ai/code/session_013xQ2dceFuWS8VLEn2xLuZE


Generated by Claude Code

…owing after undo/redo [patch]

NavigateSafelyAsync called CancelAfter outside its try, so TimeSpan.MaxValue
or a negative timeout threw ArgumentOutOfRangeException after the undo or
redo had already been applied. The token source setup now sits inside the
try, and timeouts that are not positive or exceed what CancelAfter accepts
on every target run navigation without a timeout.

Fixes #104

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

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 2a0e40a into main Sep 28, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/undoredo-104-navigation-timeout branch September 28, 2026 08:18
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.

UndoAsync/RedoAsync throw ArgumentOutOfRangeException after the change is applied when the navigation timeout is TimeSpan.MaxValue or negative

2 participants