Replies: 1 comment 4 replies
-
Code you shared looks fine. Consider adding a mutex to make sure your logic isn't being ran in multiple times in parallel, but closing windows should happen rare enough this isn't contributing to your problem. import { Mutex } from 'async-mutex';
const mutex = new Mutex();
browser.windows.onRemoved.addListener((windowId) => mutex.runExclusive(() => {
// your logic here
})); Otherwise, it seems to me like |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So I am trying to set up listeners for
browser.tabs.onRemoved
andbrowser.windows.onRemoved
in my background script.These listeners need to be async because I am trying to perform a database operation and set local storage properties.
Something like this:
but that isn't stable. Sometimes it works, sometimes it doesn't. The
resetTasks()
methods runs a supabase query.Am I doing something wrong or is there a more reliable way to do that?
I also tried everything in this SO post with the same result:
https://stackoverflow.com/a/70802055/10847224
Beta Was this translation helpful? Give feedback.
All reactions