Alarm on 3-year-old extension suddenly fires erratically

226 views
Skip to first unread message

Rob H

unread,
Sep 18, 2022, 4:43:46 AMSep 18
to Chromium Extensions
Hi, I've had an extension called reveddit real-time that has used chrome.alarms to run a task every minute for about three years without issue.

In the past few months I noticed the alarm, which is set to run every minute, is firing erratically, only once every 20 or 30 minutes. If I open the inspection window, it fires every minute as expected, as if the extension has been "woken up".

I could put in more effort to track exactly how often it is firing (suggestions welcome), but I wanted to check here too to see if anyone has any tips.

Has there been any change to when alarms activate? Or, could other extensions or my browsing activity have any impact on when alarms fire? Looking at the docs again, under chrome.alarms.create, I noticed this line:

> Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more

Unfortunately, there are no details as to why alarms may be delayed further, or by how long they could be delayed. When I first read this, I thought they meant seconds, but now I see it can be up to 30 minutes or more.

For what it's worth, the code that initializes the alarm is here in the service_worker. I don't think it's anything special.

By the way, Mozilla's create documentation does not mention any arbitrary delay:

> On Chrome, unless the extension is loaded unpackaged, alarms it creates are not allowed to fire more than once per minute. If an extension tries to set delayInMinutes to a value < 1, or when to a value < 1 minute in the future, then the alarm will fire after 1 minute. If an extension tries to set periodInMinutes to a value < 1, then the alarm will fire every minute.

Thanks for any help you can offer!

Rob

Uladzimir Yankovich

unread,
Sep 18, 2022, 2:36:13 PMSep 18
to Chromium Extensions, Rob H
We at manganum.app have a similar problem. Sometimes our users send us screenshots showing that our alarm clock sleeps for more than an hour. However, we cannot reproduce this behavior ourselves.

Jason Savard

unread,
Sep 27, 2022, 12:42:37 PMSep 27
to Chromium Extensions, yank...@manganum.app, Rob H
Several of my extension users have also been experiencing chrome.alarms that suddenly stop. Once in a broken state even it you try creating a new alarm in the debug console it fails to trigger the alarm listener.
The issue has been going on for several weeks.

Rob H

unread,
Oct 31, 2022, 7:37:30 PMOct 31
to Chromium Extensions, Rob H
For posterity, it turned out my issue was because a requested resource was being cached for an hour. So I was incorrect to say that the alarm wasn't firing. It probably was firing. Nonetheless, I did also implement the watchdog logic described here just in case.

I wish I knew how to view the console log of an extension's service worker for periods when the inspector is not open. Surely there is some way for developers to record logs for a set period so they can be reviewed later...

Simeon Vincent

unread,
Nov 1, 2022, 8:43:22 PMNov 1
to Rob H, Chromium Extensions
> Chrome limits alarms to at most once every 1 minute but may delay them an arbitrary amount more

Unfortunately, there are no details as to why alarms may be delayed further, or by how long they could be delayed. When I first read this, I thought they meant seconds, but now I see it can be up to 30 minutes or more.

To my knowledge this is meant to convey a delay of seconds during normal operation. The only case I can think of where we may have a truly arbitrary delay is if the user sleeps their device while an alarm is pending, but I think firing the alarm after the device wakes up again makes sense in that case.

We at manganum.app have a similar problem. Sometimes our users send us screenshots showing that our alarm clock sleeps for more than an hour. However, we cannot reproduce this behavior ourselves.

This could be related to suspending/sleeping. I vaguely recall hearing that the different methods of setting an alarm may behave oddly across the sleep boundary. If you decide to look into this, I'd be very interested in hearing what you find.

Simeon - @dotproto
Chrome Extensions DevRel


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/eb7588ec-d25d-492e-9e7f-4468e4483086n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages