mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #461] [MERGED] fix(extensions): bind this to globalThis in module loader #4627
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#4627
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/461
Author: @Romuromylus
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @Romuromylus
Base:
main← Head:fix/extension-loader-this-binding📝 Commits (1)
7bac3fdfix(extensions): bindthisto globalThis in module loader📊 Changes
1 file changed (+4 additions, -1 deletions)
View changed files
📝
packages/client/src/components/layout/CustomThemeInjector.tsx(+4 -1)📄 Description
Linked issue
Closes #460
Why this change
v1.5.8 shipped a CSP-safe extension loader that uses
import(blob:URL)to execute user JS withoutnew Function(). The wrapper invokes user code asexecuteExtension(marinara)with no explicitthisbinding, which under module strict mode leavesthis === undefinedinside extension code. Classic-script-style extensions that use top-levelthis.foo = barfor global assignment therefore throwTypeError: Cannot set properties of undefinedand fail silently — only the per-extensionconsole.error("[Extension:...] Failed to execute:", e)line in the loader catches it.The original
new Function("marinara", ext.js)loader (v1.5.7) ran user code withthis === globalThis. Restoring that behavior under the new module-based loader keeps the v1.5.8 CSP fix intact while not breaking the range of extension styles that worked before.This came up while reviewing #431 by @kolacheee — their alternative
<script src>proposal, since closed in favor of v1.5.8's blob-URL approach. Their work surfaced the broader question of which extension styles the new loader should support; this PR addresses the strict-modethiscorner of that question without re-litigating the architectural choice.What changed
packages/client/src/components/layout/CustomThemeInjector.tsx— one line inbuildExtensionModuleSource:Plus a 3-line comment above it explaining why.
No change to:
security-headers.tsValidation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
What was verified during preparation (boxes left unticked — reviewer should confirm independently):
pnpm checkpasses on the branch (TypeScript + ESLint + production build)..jsextension containing top-levelthis.MARINARA_THIS_TEST = "ok"plus a small banner that reportsthis's identity.FAIL — threw: Cannot set properties of undefined (setting 'MARINARA_THIS_TEST').PASS — this === window.thispatterns) verified to load and operate identically before and after the fix — full 3-column console renders, no console errors, all tab pickers populate from the API.Docs and release impact
Reviewer to decide whether this warrants a
CHANGELOG.mdline for the next patch — it's a quiet bug fix, but extension authors who hit silent strict-mode breakage may appreciate the note. Happy to add it on request.UI evidence (if applicable)
N/A — no UI surface affected.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.