Skip to content

fixed schedule handling and added tests for this bug#691

Merged
whoiskatrin merged 2 commits intomainfrom
cancel-schedule
Dec 1, 2025
Merged

fixed schedule handling and added tests for this bug#691
whoiskatrin merged 2 commits intomainfrom
cancel-schedule

Conversation

@whoiskatrin
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Dec 1, 2025

🦋 Changeset detected

Latest commit: 0c2cd04

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@691

commit: 0c2cd04

Fixed schedule handling and added tests for the bug.
@claude
Copy link
Copy Markdown

claude bot commented Dec 1, 2025

Claude Code Review

Summary: Bug fix looks good. The changes correctly handle edge cases in schedule operations.

Issues Found:

  1. Missing return value check (packages/agents/src/index.ts:1137)

    • Fixed: The bug was that result was checked with if (!result) but SQL queries return empty arrays, not null/undefined
    • The fix properly checks result.length === 0
    • This prevents the next line from attempting result[0] on an empty array
  2. Inverted logic flow (packages/agents/src/index.ts:1196-1219)

    • Fixed: Previously, cancelSchedule only emitted observability when schedule was found, but always returned true
    • Now correctly returns false when schedule not found, and only emits/deletes when found
    • This matches the updated JSDoc that promises boolean return based on success

Testing:

  • Good coverage: tests both success and failure paths for getSchedule and cancelSchedule
  • Test agent properly registered in worker.ts and wrangler.jsonc

Changeset: Properly added.

No issues to address.

@claude
Copy link
Copy Markdown

claude bot commented Dec 1, 2025

Claude Code Review

Bug Fix: Corrects schedule handling edge cases

Issues Found

  1. Missing return value in cancelSchedule (index.ts:1219): The function is documented to return boolean but the old code path did not explicitly return a value when schedule was found - it would implicitly return undefined. The fix correctly returns true after successful cancellation.

  2. Incorrect null check in getSchedule (index.ts:1137): The original check if (!result) was insufficient since SQL queries return empty arrays, not null/undefined. Fixed to check result.length === 0.

Test Coverage

The new tests properly cover:

  • Cancelling non-existent schedules (returns false)
  • Cancelling existing schedules (returns true)
  • Getting non-existent schedules (returns undefined)
  • Getting existing schedules (returns schedule object)

Test implementation looks solid with proper agent setup and assertions.

Minor Observations

The changeset description could be more specific about what bug was fixed.

Verdict: Good fix with proper test coverage. Approve.

@whoiskatrin whoiskatrin merged commit d7b2f14 into main Dec 1, 2025
6 checks passed
@whoiskatrin whoiskatrin deleted the cancel-schedule branch December 1, 2025 14:13
@github-actions github-actions bot mentioned this pull request Dec 1, 2025
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