cloudflare / cloudflare/workerd

🐛 Bug Report — Runtime APIs: setAlarm

Open
#6,866 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

## Description

**`setAlarm(Date.now())` issued from inside `alarm()` behaves inconsistently and never fires promptly.**

- In local workerd (`miniflare/vitest-pool-workers`) the re-set alarm is silently cleared when the running alarm handler completes, permanently severing an alarm chain.
- In production DOs it is retained (`getAlarm()` returns the past-due timestamp) but does not fire for tens of seconds, if at all, until the object is next disturbed.

**Note**:

`setAlarm(Date.now() + 1)` works correctly in both environments.

## Minimal repro

A Durable Object whose `alarm()` increments a counter and re-arms with `setAlarm(Date.now())`.

Expected: either both environments fire the past-due alarm promptly, or the API documents that re-arming at/behind the current time from inside `alarm()` is unsupported.

Actual: counter stalls at 1.

Work-around: with `setAlarm(Date.now() + 1)` it chains normally.

Contributor guide

Open the contributing guide

Research direction

Start with the minimal Durable Object reproduction using alarm(), setAlarm(Date.now()), and getAlarm(), then compare behavior in local workerd via miniflare/vitest-pool-workers with production DOs. Done means re-arming at the current time either fires promptly and preserves the alarm chain in both environments, or the API explicitly documents this case as unsupported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.