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

Unset "failed to initialize" error upon successful initialization #2971

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

ghostwords
Copy link
Member

Following up on #2967. Fixes another part of #2966. This PR is this bit:

We are going to follow this up with a fix for (1) where we deactivate the "failed to initialize" error when PB does in fact finish initializing successfully.

Comment on lines +127 to +134
if (self.criticalError == "Privacy Badger failed to initialize") {
delete self.criticalError;
chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
if (tabs[0]) {
self.updateBadge(tabs[0].id);
}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we setting self.criticalError to "Privacy Badger failed to initialize" in dispatcher if we always delete it? Should we check for another condition before deleting? Mainly asking to make sure I understand what's going on

Copy link
Member Author

@ghostwords ghostwords Jun 3, 2024

Choose a reason for hiding this comment

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

We set "failed to initialize" when a content script or PB's popup or options want something, and badger.INITIALIZED is still false ten seconds after PB's background process started running.

If PB does in fact finish initializing, PB didn't fail to initialize, it was just really slow. We should unset "failed to initialize" at this point, right? Not sure what other condition we should check before deleting the error.

We could take out all of the "failed to initialize" logic, but then we would back at not knowing if PB were to ever fail to initialize again. I think not knowing is quite bad because then we're silently failing some proportion of our users.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense, so do we not have to check any condition to confirm that PB actually initialized because this code won't run unless PB finished initializing?

Copy link
Member Author

@ghostwords ghostwords Jun 3, 2024

Choose a reason for hiding this comment

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

Yeah, if we got this far, badger.INITIALIZED is true.

Copy link
Contributor

@lenacohen lenacohen left a comment

Choose a reason for hiding this comment

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

LGTM! Tested locally before and after code changes. Reduced the 10 second initialization timeout to 10 ms to confirm that PB settings changes persist and the error symbol doesn't appear if PB initializes after the timeout is triggered!

ghostwords added a commit that referenced this pull request Jun 3, 2024
Unset "failed to initialize" error upon successful initialization.
@ghostwords ghostwords merged commit 8561065 into master Jun 3, 2024
2 checks passed
@ghostwords ghostwords deleted the unset-init-error branch June 3, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants