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

Content script remains "ready" even after unloading #4190

Closed
fregante opened this issue Aug 31, 2022 · 1 comment · Fixed by #4240
Closed

Content script remains "ready" even after unloading #4190

fregante opened this issue Aug 31, 2022 · 1 comment · Fixed by #4240
Assignees
Labels
bug Something isn't working runtime

Comments

@fregante
Copy link
Contributor

My logic might have been incorrect in:

See:

/**
* @file Handles the definition and state of "readiness" of the content script (CS) context.
*
* `Symbol.for(x)` maintains the same symbol until the context is invalidated, even if
* the CS is injected multiple times. This should not happen but it's something we
* need to account for: https://github.com/pixiebrix/pixiebrix-extension/issues/3510
*
* When a context is invalidated, the CS and the changes it made may remain on the page,
* but the new background is not able to message the old CS, so the CS must be injected
* again. This might cause issues if the previous CS keeps "touching" the page after
* being deactivated: https://github.com/pixiebrix/pixiebrix-extension/issues/3132
*
* Using both a symbol and an attribute accounts for these 2 situations, to detect
* and handle duplicate injections in the same session and across sessions.
*/

Related

In the situation described by that issue, our logic trips trips on the "ready" attribute and reports the content script as "ready" even if the new one hasn't been injected.

Solution

onContextInvalidated().then(() => {
  if body[READY_ATTRIBUTE] === currentUuid
    removeAttribute(body, READY_ATTRIBUTE) 
})
@fregante
Copy link
Contributor Author

@fregante fregante self-assigned this Aug 31, 2022
fregante added a commit that referenced this issue Sep 13, 2022

Unverified

This user has not yet uploaded their public signing key.
…idation handling (#4240)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime
2 participants