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

#4190: Fix content script readiness race conditions and context invalidation handling #4240

Merged
merged 5 commits into from
Sep 13, 2022

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Sep 4, 2022

What does this PR do?

Checklist

  • Test
  • Designate a primary reviewer: @BLoe

@codecov-commenter
Copy link

codecov-commenter commented Sep 4, 2022

Codecov Report

Merging #4240 (3aeb920) into main (af18acc) will decrease coverage by 0.01%.
The diff coverage is 11.53%.

@@            Coverage Diff             @@
##             main    #4240      +/-   ##
==========================================
- Coverage   48.60%   48.58%   -0.02%     
==========================================
  Files         890      890              
  Lines       26165    26175      +10     
  Branches     5392     5391       -1     
==========================================
  Hits        12717    12717              
- Misses      12527    12536       +9     
- Partials      921      922       +1     
Impacted Files Coverage Δ
src/contentScript/contentScript.ts 0.00% <0.00%> (ø)
src/contentScript/contentScriptCore.ts 0.00% <0.00%> (ø)
src/errors/contextInvalidated.ts 47.05% <0.00%> (-5.89%) ⬇️
src/telemetry/BackgroundLogger.ts 35.48% <0.00%> (ø)
src/utils.ts 62.93% <0.00%> (-1.50%) ⬇️
src/utils/expectContext.ts 0.00% <ø> (ø)
src/contentScript/ready.ts 22.72% <22.22%> (+3.67%) ⬆️
src/utils/notify.tsx 63.63% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

void onContextInvalidated().then(() => {
unsetReadyInThisDocument(uuid);
console.debug("contentScript: invalidated", uuid);
});
Copy link
Contributor Author

@fregante fregante Sep 10, 2022

Choose a reason for hiding this comment

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

Part 1:

Demo

Screen.Recording.mov

Console sequence

The "invalidated" message here marks my "refresh extension" click:

Screen Shot

// `import()` is only needed to avoid execution of its dependencies, not to lazy-load it
// https://github.com/pixiebrix/pixiebrix-extension/issues/4058#issuecomment-1217391772
// eslint-disable-next-line import/dynamic-import-chunkname
const { notify } = await import(/* webpackMode: "eager" */ "@/utils/notify");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Part 2:

  • fix the issue closer to the cause

Part 3, in the future:

@fregante fregante merged commit 851b0e3 into main Sep 13, 2022
@fregante fregante deleted the F/bug/ready-or-not-here-i-come branch September 13, 2022 00:13
@twschiller twschiller added this to the 1.7.7 milestone Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Content script remains "ready" even after unloading
4 participants