fix: clean up plugin setup script tags#7750
Merged
walterbender merged 2 commits intoJul 7, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7750 +/- ##
==========================================
+ Coverage 56.60% 56.70% +0.10%
==========================================
Files 172 172
Lines 57675 57679 +4
==========================================
+ Hits 32645 32706 +61
+ Misses 25030 24973 -57 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Remove temporary plugin setup script elements from document.head after load or load failure so repeated plugin loads do not leave stale DOM nodes behind. Related to sugarlabs#7388
e94055f to
a617346
Compare
Member
|
Question: did you run the code to ensure that plugins still load? |
Contributor
Author
|
Confirmed locally that plugins still load. I browser-tested the real built-in I also strengthened the Jest coverage so the setup Blob script is actually executed before cleanup is asserted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a remaining plugin loader cleanup path where temporary setup
<script>elements are appended todocument.headbut not removed after theyfinish loading or fail to load.
The main Blob-based plugin registry script already cleans itself up on the
current branch. However, setup scripts created later for plugin initialization
logic, such as
BLOCKPLUGINS,GLOBALS, andONLOAD, still remained in the DOMafter execution.
The first-principle issue is that these setup scripts are temporary transport
mechanisms for executing Blob-backed plugin setup code. Once a setup script has
loaded or failed, the script element is no longer needed. Keeping it in
document.headcauses repeated plugin loads to accumulate stale DOM nodes duringlong-running sessions.
Related Issue
This PR fixes #7388
PR Category
Changes Made
js/utils/utils.jsso temporary plugin setup script elements are removed fromdocument.headafter successful load.document.head.URL.revokeObjectURL(...)behavior intact so Blob URLs are still released.processPluginDatathrough the existing guarded CommonJS export path so the plugin loader behavior can be tested in Jest without changing browser loading behavior.js/utils/__tests__/utils-plugin-loader.test.jsfor:onloadonerrorTesting Performed
npx jest js/utils/__tests__/utils-plugin-loader.test.js --runInBand --coverage=falsenpm run lintnpx prettier --check js/utils/utils.js js/utils/__tests__/utils-plugin-loader.test.jsnpm testChecklist
npm run lintandnpx prettier --check .with no errors.Additional Notes for Reviewers
This PR is intentionally limited to issue #7388. It does not change plugin
execution semantics; it only removes temporary setup script elements after their
load lifecycle has completed.
The browser-facing behavior remains the same: plugin setup code still runs from
Blob-backed script elements, Blob URLs are still revoked, and setup load errors
still resolve so later setup blocks can continue.