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

Firefox: Background event page gets terminated too early? #137

Open
powellnorma opened this issue Oct 4, 2024 · 0 comments
Open

Firefox: Background event page gets terminated too early? #137

powellnorma opened this issue Oct 4, 2024 · 0 comments

Comments

@powellnorma
Copy link

powellnorma commented Oct 4, 2024

As others have described (e.g. #112 (comment) #93 (comment) #20 (comment), ..), the extension seems to not send the data reliably.

I suspect this might be due to the Background event page getting terminated too early:
https://github.com/Saghen/aw-watcher-web/blob/8ec8093b41e68a06c67f5e50218ec581901cf53a/src/background/heartbeat.ts#L67-L74

export const tabActivatedListener =
  (client: AWClient) =>
  async (activeInfo: browser.Tabs.OnActivatedActiveInfoType) => {
    const tab = await getTab(activeInfo.tabId)
    const tabs = await getTabs()
    console.debug('Sending heartbeat for tab activation', tab)
    heartbeat(client, tab, tabs.length)
  }

I suspect that before these awaits have finished, the background page is already terminated.

One hint for this is that when I debug the background page in Firefox:

  1. This issue does not happen anymore (the timeline is continuous, before it had many empty spaced)
  2. It says Background event page was not terminated on idle because a DevTools toolbox is attached to the extension. every now and then

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Background_scripts

An easy fix might be to set persistent: true in the manifest.json: #107 (comment)

Ok just tried it, the latter seems to indeed fix the issue

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

No branches or pull requests

1 participant