-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Describe the bug
When a Durable Objects alarm fails to fire (e.g., missing CACHE_PURGE_ZONE_ID/CACHE_PURGE_API_TOKEN, error in alarm handler, infrastructure issue), the past alarm timestamp remains in storage indefinitely. This causes subsequent purgeCacheByTags() calls to skip setting a new alarm, resulting in cache purge operations silently failing.
The current implementation doesn't check if an alarm is in the past:
opennextjs-cloudflare/packages/cloudflare/src/api/durable-objects/bucket-cache-purge.ts
Lines 39 to 43 in b60b670
| const nextAlarm = await this.ctx.storage.getAlarm(); | |
| if (!nextAlarm) { | |
| // Set an alarm to trigger the cache purge | |
| this.ctx.storage.setAlarm(Date.now() + this.bufferTimeInSeconds * 1000); | |
| } |
If nextAlarm is a past timestamp, no new alarm is set, creating a deadlock where alarm() never fires and tags accumulate in the database.
Steps to reproduce
- Cause alarm to fail for any reason (e.g., error in
alarm()method, possibly missingCACHE_PURGE_ZONE_ID/CACHE_PURGE_API_TOKEN) - Call
revalidateTag()which triggerspurgeCacheByTags()- alarm is set - Wait for alarm to fail
- Call
revalidateTag()again -getAlarm()returns past timestamp, no new alarm is set alarm()is never called
Expected behavior
When revalidateTag() is called after a previous alarm has failed:
- The stale past alarm should be detected and cleared
- A new alarm should be set for the future
@opennextjs/cloudflare version
1.9.1
Wrangler version
4.40.2
next info output
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8132
Available memory (MB): 32768
Available CPU cores: 10
Binaries:
Node: 22.13.1
npm: 10.9.2
Yarn: 1.22.22
pnpm: 9.14.2
Relevant Packages:
next: 15.5.4 // Latest available version is detected (15.5.4).
eslint-config-next: 15.5.4
react: 19.1.1
react-dom: 19.1.1
typescript: 5.6.3
Next.js Config:
output: standaloneAdditional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status