Reject NaN timeout durations before scheduling - #119
Open
OskarEichler wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject NaN before creating a timeout request or delegating to a fiber scheduler. Test for a non-negative comparison instead of only testing for a negative comparison; NaN satisfies neither.
Reproduction
With an active block, the old request has a NaN deadline: neither its wait condition nor its expiry comparison succeeds, so the watcher repeatedly revisits it. An isolated bounded reproduction observed the watcher running until the request was cancelled. No throughput/CPU benchmark claim is made.
Focused checks cover both exception modes, nil/zero/positive integer/float/rational values, negative/infinite-negative values and rejection before scheduler delegation.
Verification
295667aac44220ddfd10db014e766ae8d313cfb8.bundle exec rake test: 36 tests / 81 assertions / zero failures or errors, baseline and this branch. Includes the existing signal, fork, Ractor, exception and mocked-scheduler cases.git diff --checkpass. Supplemental RuboCop Lint retains the same two existing offenses; no lint-clean claim.Compatibility and limitations
NaN now raises ArgumentError without yielding, matching the documented non-negative-number requirement. Negative inputs retain that error. This does not restore the Numeric class restriction removed in 7d2af46; existing duck typing and zero/nil behavior remain. Positive infinity and very large intervals are a separate issue, not fixed in this PR.
The same runtime file is shipped in 0.6.1; this patch can be adopted without a release upgrade. Ruby >= 2.6 and the empty runtime dependency set remain unchanged. No production access or external network diagnostic was used; other Ruby/OS combinations and full scheduler implementations were not run locally.