Skip to content

Conversation

@tesharp
Copy link

@tesharp tesharp commented Aug 7, 2025

According to docs the alarmprops is optional. Getting this error without, and it doesnt keep the container alive as long as defined in sleepAfter.

TypeError: Cannot read properties of undefined (reading 'isRetry')
    at MyContainerDO.alarm (index.js:12141:27)
    at index.js:11740:13

@tesharp tesharp changed the title Alarm proprs is optional Alarm props is optional Aug 7, 2025
Comment on lines +1045 to +1046
override async alarm(alarmProps?: { isRetry: boolean; retryCount: number }): Promise<void> {
if (alarmProps?.isRetry && alarmProps?.retryCount > MAX_ALARM_RETRIES) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
override async alarm(alarmProps?: { isRetry: boolean; retryCount: number }): Promise<void> {
if (alarmProps?.isRetry && alarmProps?.retryCount > MAX_ALARM_RETRIES) {
override async alarm(alarmProps?: AlarmInvocationInfo): Promise<void> {
if (alarmProps?.isRetry && alarmProps?.retryCount > MAX_ALARM_RETRIES) {

(i know this was already here, but while we're in the area we may as well make this use the actual type from workers-types instead of redefining it)

Copy link
Collaborator

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

Thanks!

@emily-shen
Copy link
Collaborator

weird though because it should always be present (apparently the type is like that for backwards compatibility) - does this happen for you consistently, or is it flaky? is this in local dev or prod? if local dev, what version of wrangler or vite?

@tesharp
Copy link
Author

tesharp commented Aug 7, 2025

I got the error consistently, but since it should always be present I looked a bit more in details. Been using https://github.com/evanderkoogh/otel-cf-workers to get traces, and this created a proxy for alarm that did not pass the arguments correctly. So the problem in this case was this library.
Since the argument is optional according to docs (but should never be..) should this be added or not?

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.

2 participants