Skip to content

Keep alarm test times out of reach of setAlarm's past-time clamp - #82

Merged
MiguelsPizza merged 1 commit into
mainfrom
alex/fix-alarm-test-flake
Sep 23, 2026
Merged

MiguelsPizza merged 1 commit into
mainfrom
alex/fix-alarm-test-flake

Conversation

@MiguelsPizza

Copy link
Copy Markdown
Contributor

The release PR #78 failed CI on a flaky runtime unit test. This fixes the test, not the runtime.

Cause. The alarm tests in src/server/actor-container.test.ts armed Date.now() + 5 and then delivered that exact time. setAlarm() stores the later of the requested time and now. When a slow runner stalls for five milliseconds before the write lands, the stored alarm is a different time and the delivery is canceled. If another millisecond passes, the delivery instead runs through the "alarm already past" branch.

CI hit this twice today:

Run Test Failure
#78, 18:20 ctx.abort honors retryAlarm: false outcome "canceled", expected "aborted"
#78, 13:56 same same
main after #80 the handler is handed the scheduled time and the retry count one delivery instead of two

Fix. Arm the ten affected tests a minute out. No runtime code changes, so no changeset.

Check. Freezing Date.now() five milliseconds past the old margin reproduces the CI assertion on the old times and passes on the new ones. The file passes 75 of 75.

🤖 Generated with Claude Code

The alarm tests armed `Date.now() + 5` and then delivered that exact time.
setAlarm() stores max(time, now), so on a runner that stalls for five
milliseconds before the write lands the stored alarm is a different time,
and the delivery is canceled (or, a millisecond later, runs through the
"alarm already past" branch). CI hit both shapes: "ctx.abort honors
retryAlarm: false" returned outcome "canceled" on the release PR, and
"the handler is handed the scheduled time and the retry count" saw only
one delivery on main.

Arm a minute out instead. Freezing Date.now() five milliseconds past the
old margin reproduces the CI assertion on the old times and passes on the
new ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MiguelsPizza
MiguelsPizza merged commit 8c6ab9b into main Sep 23, 2026
1 check passed
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.

1 participant