Skip to content

fix: validate invalid createTimer inputs#288

Merged
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/createtimer-invalid-input-validation
Jul 8, 2026
Merged

fix: validate invalid createTimer inputs#288
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/createtimer-invalid-input-validation

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #220

…alid Date

createTimer() silently accepted NaN, Infinity, and invalid Date objects,
producing timers with corrupted protobuf Timestamps (defaulting to Unix
epoch). This caused timers to fire immediately instead of at the intended
time, with no error reported to the orchestrator author.

Add validation for:
- Non-finite number inputs (NaN, Infinity, -Infinity): throws with
  descriptive message
- Invalid Date objects (NaN timestamp): throws with descriptive message
- Valid inputs (finite numbers, valid Dates, zero, negatives): accepted
  as before

Fixes #220

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens RuntimeOrchestrationContext.createTimer() input handling so invalid values don’t silently produce corrupted durable timer timestamps (notably falling back to the Unix epoch), addressing issue #220.

Changes:

  • Added runtime validation in createTimer() to reject non-finite numeric delays (NaN, ±Infinity) and invalid Date objects.
  • Added Jest coverage for rejected/accepted createTimer() inputs via executor-driven orchestration execution.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Adds validation for createTimer() inputs before creating timer actions.
packages/durabletask-js/test/createtimer-validation.spec.ts Adds unit tests covering invalid and valid createTimer() inputs and expected outcomes.

Comment thread packages/durabletask-js/src/worker/runtime-orchestration-context.ts Outdated
YunchuWang and others added 2 commits July 8, 2026 11:35
Reject finite numeric timer delays that overflow Date after conversion, preventing invalid timestamps from reaching protobuf serialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Separate number, Date, and invalid runtime input handling before validating the computed timer date.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YunchuWang
YunchuWang merged commit f91c8a9 into main Jul 8, 2026
28 checks passed
@YunchuWang
YunchuWang deleted the copilot-finds/bug/createtimer-invalid-input-validation branch July 8, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: createTimer() silently accepts NaN, Infinity, and invalid Date inputs, producing timers that fire at wrong times

4 participants