remove temporary plugin loader scripts from document.head after execution#7389
remove temporary plugin loader scripts from document.head after execution#7389sahu-virendra-1908 wants to merge 2 commits into
Conversation
|
@sum2it @omsuneri @walterbender kindly review this PR. Happy to make any improvements or changes if required. |
|
🧪 Jest Test Results ❌ Some Jest tests failed. Please check the logs and fix the issues before merging. Coverage: Statements: 47% | Branches: 38.51% | Functions: 51.47% | Lines: 47.42% Note: These failures may be introduced by this PR or may already exist in the master branch. Failed Tests: |
|
@walterbender sir The failing DictActions.test.js appears unrelated to this PR. |
|
This PR has merge conflicts with Please rebase your branch: # Add upstream remote (one-time setup)
git remote add upstream https://github.com/sugarlabs/musicblocks.git
# Fetch latest master and rebase
git fetch upstream
git rebase upstream/master
# Resolve any conflicts, then:
git push --force-with-lease origin YOUR_BRANCH
|
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 47% | Branches: 38.51% | Functions: 51.47% | Lines: 47.42% |
|
@walterbender sir, I also changed The old test was asserting that |
The debug console.log was removed from DictActions.setValue() as it was a leftover from development. The existing test was asserting that console.log fires on every setValue call, which was the bug behavior. Updated test to: 1. Assert console.log is NOT called (correct production behavior) 2. Assert the value is actually stored correctly 3. Add mockRestore() for proper spy cleanup :wq#
2b44315 to
28a870a
Compare
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 47.62% | Branches: 38.86% | Functions: 52.45% | Lines: 48.02% |
What this fixes
While testing plugin loading in Music Blocks, I noticed that dynamically injected plugin
<script>elements remain permanently attached todocument.headafter plugin execution completes.The issue happens inside
processPluginData()in:Current implementation:
The script executes correctly, but the injected DOM node is never cleaned up afterward.
Because plugin loading can happen multiple times in the same session, repeated plugin reloads gradually accumulate unused
<script>tags inside<head>.Related Issue #7388
Root cause
The dynamically created Blob-based loader scripts are appended to the DOM but never removed after:
Current behavior:
The Blob URL is revoked correctly, but the actual
<script>element remains in the document permanently.This affects:
Over long sessions,
document.headcontinuously grows with unused script nodes.What I changed
Added cleanup for dynamically injected plugin scripts after execution completes.
Updated both:
script.onloadscript.onerrorto remove the temporary script node from
document.head.Result
document.headno longer accumulates unused plugin script tagsPR Category
Checklist