mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5555] [MERGED] fix(common): resolve script errors when switching sandbox modes #5257
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5257
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/hoppscotch/hoppscotch/pull/5555
Author: @jamesgeorge007
Created: 11/3/2025
Status: ✅ Merged
Merged: 11/4/2025
Merged by: @jamesgeorge007
Base:
patch← Head:fix/script-execution-sandbox-switching📝 Commits (2)
7d74f44fix(common): resolve script errors when switching sandbox modesdc16c54refactor(common): rename MODULE_PREFIX_REGEX for clarity📊 Changes
5 files changed (+44 additions, -13 deletions)
View changed files
📝
packages/hoppscotch-common/src/components/MonacoScriptEditor.vue(+2 -3)📝
packages/hoppscotch-common/src/components/collections/index.vue(+6 -2)📝
packages/hoppscotch-common/src/composables/codemirror.ts(+5 -6)📝
packages/hoppscotch-common/src/helpers/RequestRunner.ts(+9 -2)➕
packages/hoppscotch-common/src/helpers/scripting.ts(+22 -0)📄 Description
Closes FE-1046.
Scripts edited in the experimental sandbox were failing to execute when users switched back to the legacy sandbox. This happened because Monaco powered editor adds an
export {};prefix for TypeScript support, but the legacy sandbox can't handle module syntax and throwsUnexpected token export.What's changed
~/hoppscotch-common/src/helpers/scripting.tsto centraliseMODULE_PREFIXconstant and utilities, alongside accounting for import path updates.export {};prefix inRequestRunner.tsbefore executing scripts in legacy sandboxThe prefix is only stripped at execution time for the legacy sandbox - it's preserved in the underlying state, so switching back to experimental mode continues to work correctly.
Notes to reviewers
Experimental scripting sandbox(Legacy scripting sandbox) from settings and populate the pre/post request editor with a sample snippet.Experimental scripting sandbox), navigate back to the editor populated in the previous step and make a simple edit. For instance, inserting a new line.Legacy scripting sandbox), return to the request tab, attempt to send the request and observe the exception encountered.Also, ensure to verify the collection exports (both individual & workspace level bulk) don't include
export {};\nin the exported contents.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.