mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2946] [Issue]: Toggling or editing one extension restarts every other enabled extension #1522
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1522
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2946
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The code that runs extension JavaScript is keyed on the whole list of extensions. So changing any single extension — toggling one on/off, editing it, deleting it, or importing another — tears down and re-runs every enabled extension's code from scratch, not just the one you touched.
For extensions that just register a few event listeners this is mostly invisible (they get cleaned up and re-registered). But any extension that keeps state in memory loses it, and any one-time side effect it did outside the cleanup API (a raw
appendChild, a global counter, a self-registering widget) gets duplicated each time. So a user who flips one extension can silently corrupt or double up an unrelated extension.How to reproduce (try it yourself)
A loaded #1.You'll see: Ext A re-runs every time you touch Ext B —
A loaded #2, then#3— even though you never changed Ext A, and its in-memory state (window.__a) climbs because the whole module is re-evaluated.Expected: changing Ext B affects only Ext B; Ext A keeps running with its existing state untouched.
Where it is
packages/client/src/components/layout/CustomThemeInjector.tsx— the "Execute enabled extension JS" effect at lines 103-271, whose dependency array is[installedExtensions](line 271). The teardown at 268-270 runscleanupFnsfor all extensions, and each run rebuilds every extension from scratch (freshapiKeyat 116, fresh Blob/objectURL/import at 248-252). It's driven byuseUpdateExtensioninvalidating the extensions query (use-extensions.ts:67-76,staleTime: 0), which hands React a new array reference.What's happening
When one extension's data changes, the query returns a new top-level array reference, the effect's dependency changes, and the single effect cleans up and re-imports every enabled extension — there's no per-extension isolation. (For the record: it is not caused by the 15s refetch — unchanged data keeps the same reference via structural sharing — and not a reorder, since the server orders by
installedAt. A single element's data change is enough to break reference equality of the array.)Suggested fix
Isolate extensions from each other: render one small keyed component (or run one keyed effect) per
ext.id, so only the changed extension reloads. Or diffinstalledExtensionsbyid+ a content hash of(enabled, css, js)and only tear down / re-load the extensions that actually changed, leaving the rest running.AI-investigated against v2.0.6; cited lines were read and the repro verified. Please confirm before fixing.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Fixed on staging: extension CSS/JS injection is isolated per extension, so changing one extension no longer tears down and reruns every other enabled extension.