# WebExtension - Alarm stop working after popup loaded

**URL:** <https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658>\
**Category:** Development\
**Created:** [December 20, 2017, 10:19am UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658 "2017-12-20T10:19:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeZla](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/lezla/32/23300_2.png) [@LeZla](https://discourse.mozilla.org/u/LeZla)\
**Post date:** [December 20, 2017, 10:19am UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/1 "2017-12-20T10:19:36Z")

</div>

Hi there,

I have an extension working almost well, except one point. I have a background script that fires an alarm every ten minutes. The alarm updates a value on the icone in the menu bar. This works fine.  
However a click on this icon, loads a popup, it also works fine.  
But from there, the alarm from my background script is no more fired.

I guess it has something to see with persistent scripts not allowed in firefox (it works well in chrome), but how can I make it works ?

Thanks for your answers.  
Regards.

---

<div class="post-metadata">

**Author:** ![freaktechnik](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/freaktechnik/32/37766_2.png) [@freaktechnik](https://discourse.mozilla.org/u/freaktechnik)\
**Post date:** [December 20, 2017, 3:27pm UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/2 "2017-12-20T15:27:02Z")

</div>

In Firefox the background page is persistent. Is the alarm repeating or do you have to queue it every time?

---

<div class="post-metadata">

**Author:** ![LeZla](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/lezla/32/23300_2.png) [@LeZla](https://discourse.mozilla.org/u/LeZla)\
**Post date:** [December 20, 2017, 3:42pm UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/3 "2017-12-20T15:42:34Z")

</div>

Thanks for your answer.  
The alarm is repeating, here is the code to create it :  
`browser.alarms.create("updateFavVisits", {delayInMinutes: 0.1, periodInMinutes: 10} );`

And here is how I catch it :  
`browser.alarms.onAlarm.addListener(function( alarm ) { setIconValue(); });`

Thanks

---

<div class="post-metadata">

**Author:** ![jorgev](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jorgev](https://discourse.mozilla.org/u/jorgev)\
**Post date:** [January 3, 2018, 8:53pm UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/4 "2018-01-03T20:53:48Z")

</div>

Where are the alarm and the listener created?

---

<div class="post-metadata">

**Author:** ![LeZla](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/lezla/32/23300_2.png) [@LeZla](https://discourse.mozilla.org/u/LeZla)\
**Post date:** [January 4, 2018, 4:31pm UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/5 "2018-01-04T16:31:52Z")

</div>

Both alarms and listener are in a background.js file called via the manifest.json :  
“background”: {  
“scripts” : [“dist/js/jquery.js”, “dist/js/background.js”]  
}

---

<div class="post-metadata">

**Author:** ![jorgev](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jorgev](https://discourse.mozilla.org/u/jorgev)\
**Post date:** [January 9, 2018, 5:41pm UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/6 "2018-01-09T17:41:09Z")

</div>

Are you sure the alarm is no longer fired? Could it be that it is fired but the icon is no longer updated? Have you checked the Browser Console for any errors?

Having a file to test would be useful to try to find the problem.

---

<div class="post-metadata">

**Author:** ![LeZla](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/lezla/32/23300_2.png) [@LeZla](https://discourse.mozilla.org/u/LeZla)\
**Post date:** [January 10, 2018, 8:48am UTC](https://discourse.mozilla.org/t/webextension-alarm-stop-working-after-popup-loaded/23658/7 "2018-01-10T08:48:36Z")

</div>

Hi @jorgev  
Yes I’m sure the alarm is not fired, as it fired a function with a console.log  
And I have no errors in the console.

I’ll try to build a quick extension to show the problem. I may need a couple of days.

Thanks for your help.
