Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Durable Objects] Adding info on alarmInfo parameter for alarm() #18591

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/content/docs/durable-objects/api/alarms.mdx
Copy link
Collaborator

@elithrar elithrar Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a changelog entry for this please?

Durable Objects [Alarms](/durable-objects/api/alarms/) now have a new `alarmInfo` argument that provides more details about an alarm invocation, including the `retryCount` and `isRetry` to signal if the alarm was retried.

Ensure you are using `@cloudflare/workers-types` version `4.20241106.0` or later to see the new method signature.

cc @vy-ton

Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ Alarms can be used to build distributed primitives, like queues or batching of w

### `alarm`

- `alarm()`: <Type text='void' />
- <code>alarm(`alarmInfo`<Type text="Object"/>)</code>`: <Type text='void' />

- Called by the system when a scheduled alarm time is reached.

- The optional parameter `alarmInfo` object has two properties:
- `retryCount` <Type text="number"/>: The maximum number of retries if the alarm does not wake up the Durable Object.
- `isRetry` <Type text="boolean"/>: A boolean value to indicate if the alarm should be retried.

- The `alarm()` handler has guaranteed at-least-once execution and will be retried upon failure using exponential backoff, starting at 2 second delays for up to 6 retries. Retries will be performed if the method fails with an uncaught exception.

- This method can be `async`.
Expand Down
6 changes: 5 additions & 1 deletion src/content/docs/durable-objects/api/base.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ export class MyDurableObject extends DurableObject {

### `alarm`

- <code>alarm()</code>: <Type text="Promise <void>"/>
- <code>alarm(`alarmInfo`<Type text="Object"/>)</code>: <Type text="Promise <void>"/>

- Called by the system when a scheduled alarm time is reached.

- The optional parameter `alarmInfo` object has two properties:
- `retryCount` <Type text="number"/>: The maximum number of retries if the alarm does not wake up the Durable Object.
- `isRetry` <Type text="boolean"/>: A boolean value to indicate if the alarm should be retried.
Oxyjun marked this conversation as resolved.
Show resolved Hide resolved

- The `alarm()` handler has guaranteed at-least-once execution and will be retried upon failure using exponential backoff, starting at two second delays for up to six retries. Retries will be performed if the method fails with an uncaught exception.

- This method can be `async`.
Expand Down
Loading