MV3 and chrome.alarms

51 views
Skip to first unread message

Pavel Aronovich

unread,
Oct 13, 2023, 12:11:16 PM10/13/23
to Chromium Extensions
I use one chrome.alarm in the extension, which is installed in chrome.runtime.onInstalled:

chrome.alarms.clearAll(function() {
    chrome.alarms.create(ALARM_CHECK_TAB, { delayInMinutes: 1.0, periodInMinutes: 1.0 });
});

Recently we noticed that at some point there is not a single alarm in the browser.
How can this be?

Pavel Aronovich

unread,
Oct 13, 2023, 12:12:55 PM10/13/23
to Chromium Extensions, Pavel Aronovich
I'm doing the cleanup because there were 2 timers in earlier versions of the extension.

пятница, 13 октября 2023 г. в 19:11:16 UTC+3, Pavel Aronovich:

wOxxOm

unread,
Oct 14, 2023, 6:35:45 AM10/14/23
to Chromium Extensions, Pavel Aronovich
>  How can this be?

Sounds like a bug i.e. the service worker was terminated while waiting for the API to return after calling clearAll but before running the callback.

Pavel Aronovich

unread,
Oct 14, 2023, 6:39:47 AM10/14/23
to Chromium Extensions, wOxxOm, Pavel Aronovich
maybe then do so?

chrome.alarms.clearAll();
chrome.alarms.create(ALARM_CHECK_TAB, {layInMinutes: 1.0, periodInMinutes: 1.0 });
суббота, 14 октября 2023 г. в 13:35:45 UTC+3, wOxxOm:

wOxxOm

unread,
Oct 14, 2023, 6:52:34 AM10/14/23
to Chromium Extensions, Pavel Aronovich, wOxxOm
Maybe don't use clearAll, but instead use getAll, then check and remove the wrong items explicitly. Normally there should be just a few items.

Pavel Aronovich

unread,
Oct 14, 2023, 6:55:21 AM10/14/23
to Chromium Extensions, wOxxOm, Pavel Aronovich
I'll think about it, thanks

суббота, 14 октября 2023 г. в 13:52:34 UTC+3, wOxxOm:
Reply all
Reply to author
Forward
0 new messages