[PR #5433] [MERGED] fix(js-sandbox): resolve errors with pw.env namespace in legacy sandbox #5201

Closed
opened 2026-03-17 02:40:23 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5433
Author: @jamesgeorge007
Created: 10/3/2025
Status: Merged
Merged: 10/6/2025
Merged by: @jamesgeorge007

Base: patchHead: fix/legacy-js-sandbox-env-methods


📝 Commits (2)

  • f7a9bac fix(js-sandbox): resolve errors with pw.env namespace in legacy sandbox
  • 4bc8867 fix: add missing pw.env methods in post-request types

📊 Changes

2 files changed (+22 additions, -15 deletions)

View changed files

📝 packages/hoppscotch-common/src/types/post-request.d.ts (+3 -1)
📝 packages/hoppscotch-js-sandbox/src/utils/shared.ts (+19 -14)

📄 Description

The legacy scripting sandbox was returning environment methods as a flat object under methods, requiring consumers to manually wrap them in an env property. This inconsistency arose because the experimental sandbox uses bootstrap code (powered by faraday-cage) that defines the pw.env structure, while the legacy sandbox doesn't.

image image

Also updates the post-request type definitions, accounting for missing pw.env methods. These are consumed by the Monaco-based scripting editors in the experimental scripting sandbox for IntelliSense.

image

Closes FE-1026, FE-1027.

What's changed

  • Updated getSharedEnvMethods() return type for legacy sandbox to wrap methods in env property.
  • Modified implementation to return methods: { env: { get, getResolve, set, unset, resolve } }.
  • Updated JSDoc comment to clarify the architectural difference between legacy and experimental sandboxes.
  • This centralises the structure at the source, preventing the need to add wrapping at all consumption points.

Notes to reviewers

Verify the relevant script execution flows in the legacy scripting sandbox, and that the issue being addressed is resolved.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5433 **Author:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Created:** 10/3/2025 **Status:** ✅ Merged **Merged:** 10/6/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `fix/legacy-js-sandbox-env-methods` --- ### 📝 Commits (2) - [`f7a9bac`](https://github.com/hoppscotch/hoppscotch/commit/f7a9bac0795a5c3d21f328b1543fc9a050d1cde8) fix(js-sandbox): resolve errors with pw.env namespace in legacy sandbox - [`4bc8867`](https://github.com/hoppscotch/hoppscotch/commit/4bc8867d9098143ea7bf2313ea7846e0e8d2fa8b) fix: add missing `pw.env` methods in post-request types ### 📊 Changes **2 files changed** (+22 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/types/post-request.d.ts` (+3 -1) 📝 `packages/hoppscotch-js-sandbox/src/utils/shared.ts` (+19 -14) </details> ### 📄 Description The legacy scripting sandbox was returning environment methods as a flat object under `methods`, requiring consumers to manually wrap them in an `env` property. This inconsistency arose because the experimental sandbox uses bootstrap code (powered by [faraday-cage](https://npmjs.com/package/faraday-cage)) that defines the `pw.env` structure, while the legacy sandbox doesn't. <img width="2326" height="1656" alt="image" src="https://github.com/user-attachments/assets/171c0b04-f270-46c1-8308-f64f228fd73e" /> <img width="719" height="224" alt="image" src="https://github.com/user-attachments/assets/936d3297-6e6d-4b0e-b2f5-4abc5f3d026e" /> Also updates the post-request type definitions, accounting for missing `pw.env` methods. These are consumed by the Monaco-based scripting editors in the experimental scripting sandbox for IntelliSense. <img width="628" height="129" alt="image" src="https://github.com/user-attachments/assets/32585d8b-a761-4a4a-af93-9c5aa2275a8c" /> Closes FE-1026, FE-1027. ### What's changed - Updated `getSharedEnvMethods()` return type for legacy sandbox to wrap methods in `env` property. - Modified implementation to return `methods: { env: { get, getResolve, set, unset, resolve } }`. - Updated JSDoc comment to clarify the architectural difference between legacy and experimental sandboxes. - This centralises the structure at the source, preventing the need to add wrapping at all consumption points. ### Notes to reviewers Verify the relevant script execution flows in the legacy scripting sandbox, and that the issue being addressed is resolved. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:40:23 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5201
No description provided.