mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #460] [Issue]: extension loader leaves this undefined inside module wrapper, breaking classic-script-style extensions #203
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#203
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 @Romuromylus on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/460
Summary
The v1.5.8 extension loader in
CustomThemeInjector.tsxwraps user JS inside a function and invokes it asexecuteExtension(marinara)(no explicitthisbinding). Because the wrapper is loaded as an ES module viaimport(blob:URL), the function inherits strict mode, andthisisundefinedinside extension code. This silently breaks classic-script-style extensions that rely onthis === windowfor top-level global assignment patterns likethis.foo = bar.Expected behavior
Inside extension code,
thisshould be bound to the global object (matching v1.5.7'snew Function(\"marinara\", ext.js)semantics, wherethiswas the global object when invoked without an explicit binding). Extensions written in classic-script style should continue to work after the v1.5.8 loader change.Actual behavior
thisisundefinedat the top level of extension code. Top-levelthis.foo = barthrowsTypeError: Cannot set properties of undefined (setting 'foo'). The extension fails silently — the only trace is the per-extensionconsole.error(\"[Extension:...] Failed to execute:\", e)line.Steps to reproduce
Install Marinara Engine v1.5.8.
Create a
.jsextension file containing only:Settings → Extensions → Import the file → refresh.
Open DevTools → Console.
Observed:
Uncaught TypeError: Cannot set properties of undefined (setting 'SOMETHING').Expected:
this is: window.Environment
Logs, screenshots, or video
Verified end-to-end on a local fork with a candidate fix applied. Test extension prints
this === window(green pass banner) after the fix, vs. theTypeErrorabove on stock v1.5.8.Additional context
Discovered while reviewing #431 (kolacheee's alternative server-side-loaded
<script src>approach, which was closed in favor of the v1.5.8 blob-URL loader). The architectural choice to keep the loader client-only is fine; the strict-modethisissue is a small follow-up to make the v1.5.8 loader compatible with the same range of extension styles the v1.5.7 loader supported.Template check