Durable Objects: Prevent alarm retries with ctx.abort()
Added the retryAlarm option to ctx.abort() so that alarms can be permanently stopped instead of automatically retrying after a Durable Object reset. This is useful for tasks like cleanup operations that should only run once.
By default, an alarm interrupted by ctx.abort() retries after the Durable Object resets. Pass { retryAlarm: false } when the alarm should stop instead:
import { DurableObject } from "cloudflare:workers";
export class CleanupTask extends DurableObject {
async alarm() {
await this.ctx.storage.deleteAll();
this.ctx.abort("Cleanup complete", { retryAlarm: false });
}
}src/index.tstsimport { DurableObject } from "cloudflare:workers";
export class CleanupTask extends DurableObject {
async alarm(): Promise<void> {
await this.ctx.storage.deleteAll();
this.ctx.abort("Cleanup complete", { retryAlarm: false });
}
}
For example, an alarm that deletes its storage can use this option to avoid repeating the cleanup or re-running the Durable Object constructor.
Alarms can run concurrently with other requests to the same Durable Object. If another request calls ctx.abort() while an alarm is running, the retryAlarm option on that call also controls whether the alarm retries.
The default retry prevents an unrelated request from permanently canceling the alarm. Set retryAlarm: false on every abort path that should stop an in-progress alarm, not only on calls from the alarm handler. Existing calls to ctx.abort() keep retrying alarms.
For local development, retryAlarm requires Wrangler 4.126.0 or later.
For more information, refer to ctx.abort().
Source: original entry ↗
More from Cloudflare
Follow Cloudflare to get its new changes in your feed and email digest.
Rules - Remove surrounding bytes with trim functions
Cloudflare Rules now supports three new functions—trim(), trim_start(), and trim_end()—to remove surrounding bytes from values before comparison. These functions work across all HTTP products on all plans and can remove ASCII whitespace by default or custom byte sets specified as an optional parameter.
DNS - Configure Advanced Custom Nameservers with nameserver sets
Nameserver sets are now available in beta for Enterprise accounts, allowing you to group custom nameserver names with Cloudflare-assigned IP addresses and assign them to multiple zones. This new approach replaces legacy custom_ns sets with reusable, immutable objects that support up to 3 IPv4 and 3 IPv6 addresses per nameserver and can leverage Advanced anycast network groups for improved resiliency.
Emergency WAF managed rule for active RCE vulnerability
Cloudflare released an emergency WAF update with a new managed rule to block exploitation of a critical remote code execution vulnerability in popular web frameworks. The Generic Rules - Remote Code Execution detection prevents attackers from executing arbitrary system commands via malicious input with invalid path sequences.