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

Background workers are not permanent in Manifest v3 #15

Open
polcak opened this issue Apr 25, 2024 · 1 comment
Open

Background workers are not permanent in Manifest v3 #15

polcak opened this issue Apr 25, 2024 · 1 comment

Comments

@polcak
Copy link

polcak commented Apr 25, 2024

Hello,

it looks like you are using Manifest v3 and it looks like you store state in you background workers.

For example, let us focus on check_git

let check_git;
. The extension writes to that variable in set_options (
let check_git;
) and in the onMessage listener (
check_git = request.value;
). The extension reads the value in onHeaderReceived WebRequest API listener
if (check_git) {
.

First of all, you are using a global variable and the code looks like it can produce race conditions for that variable if the onMessage listener is executed in short time with different content for the check_git variable. I have not checked if this is this can happen.

My main point is that the worker could have been destroyed between you store the value to the variable and onHeaderReceived fires. the code would broke if the variable should hold true. If I am looking right at the code, the variable would be undefined when the service worker respawns.

@davtur19
Copy link
Owner

For now I'm not using manifestV3 yet, I was waiting for it to be supported by FireFox (I tried a few months ago and it didn't work) and I just did some testing on chrome and it seemed to work fine, until it's mandatory I don't think I'll make any changes unless necessary.

Anyway thanks for pointing out that in manifestV3 this might cause problems.

PR are welcome.

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

2 participants