Skip to content

Conversation

@HueCodes
Copy link

parseCronExpression throws for malformed cron strings. In the alarm
handler this prevents remaining schedules from executing and leaves
the invalid schedule in the database, blocking future alarms.

Wrap in try/catch and remove invalid schedules to unblock the loop.

@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: 6b2d554

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

@threepointone
Copy link
Contributor

we should probably validate them when adding

@HueCodes
Copy link
Author

Yeah, getNextCronTime at line 1108 already throws for invalid expressions on creation. This just handles the edge case of corrupted data. Happy to add explicit validation there too if you'd prefer. Just let me know and thanks for the quick response!

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

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

commit: 6b2d554

@threepointone
Copy link
Contributor

can you explain to me how there would be corrupt data if we were always validating the input?

@HueCodes
Copy link
Author

Good point. I was focused on catching edge cases at read-time, but validation at input makes more sense as the primary defense. I’ll update the PR after work. Still learning so thanks for your input.

Reject invalid cron expressions when schedule() is called rather than
failing silently in the alarm handler.
@HueCodes
Copy link
Author

Updated to validate cron expressions at input in schedule()

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