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

Re-inject site scripts when background process wakes up from idle #40

Merged
merged 4 commits into from
May 30, 2024

Conversation

jdgarcia
Copy link
Contributor

https://gitkraken.atlassian.net/browse/GKDOTDEV-612

Repro steps are super easy (recommend Firefox since it's easy to tell if the background script is running)

  1. In Firefox, open about:debugging#/runtime/this-firefox
  2. don't interact with the extension (don't open launchpad, don't go to provider websites), and after a minute or two, the browser will turn off the background script
  3. open a link to a repo/PR/commit/etc. the background script will wake up and re-inject the scripts but the page will have already loaded so it won't have the injected buttons
Screenshot 2024-05-28 at 10 56 44 AM

src/background.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@gitkrakel gitkrakel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed this will re-inject into existing tabs if other tabs are already running the script.

Technically this isn't a problem for the user since all injection scripts are written to remove existing injections each time it renders, but it's an efficiency problem since there will be new event listeners each time the script is injected.

@gitkrakel gitkrakel self-requested a review May 30, 2024 01:07
@jdgarcia jdgarcia merged commit f54c9bf into main May 30, 2024
1 check passed
@jdgarcia jdgarcia deleted the fix-wakeup-race-condition branch May 30, 2024 02:20
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

Successfully merging this pull request may close these issues.

2 participants