fix: reject non-finite retry policy values#274
Open
YunchuWang wants to merge 1 commit into
Open
Conversation
RetryPolicy's constructor validated numeric parameters using comparison operators (<=, <) which silently accept NaN because all NaN comparisons return false in JavaScript. For example, NaN <= 0 evaluates to false, so NaN maxNumberOfAttempts passed validation and caused infinite retries since attemptCount >= NaN is always false. Add Number.isFinite() guards before all comparison checks to reject NaN, Infinity, and -Infinity for all numeric parameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens RetryPolicy constructor validation to reject non-finite numeric inputs (NaN/±Infinity) so retry scheduling can’t enter invalid or infinite-retry states, addressing issue #230.
Changes:
- Added
Number.isFinite()guards forRetryPolicynumeric options and updated corresponding error messages. - Expanded Jest coverage to assert NaN/Infinity rejection across retry policy parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/durabletask-js/src/task/retry/retry-policy.ts | Adds finite-number validation for retry policy inputs and updates thrown error messages accordingly. |
| packages/durabletask-js/test/retry-policy.spec.ts | Updates existing validation assertions and adds new tests for NaN/Infinity rejection behavior. |
Comment on lines
82
to
86
| if ( | ||
| maxRetryIntervalInMilliseconds !== undefined && | ||
| maxRetryIntervalInMilliseconds !== -1 && | ||
| maxRetryIntervalInMilliseconds < firstRetryIntervalInMilliseconds | ||
| (!Number.isFinite(maxRetryIntervalInMilliseconds) || maxRetryIntervalInMilliseconds < firstRetryIntervalInMilliseconds) | ||
| ) { |
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
Fixes #230