[PR #5594] [CLOSED] feat: add fetch support in pre-request scripts #5410,#3305 #5275

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

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5594
Author: @HuynhTuanWD
Created: 11/18/2025
Status: Closed

Base: mainHead: feat/support-fetch-prescript


📝 Commits (1)

  • 9bd264c feat: add fetch support in pre-request scripts (#5410)

📊 Changes

6 files changed (+450 additions, -126 deletions)

View changed files

📝 packages/hoppscotch-common/src/helpers/preRequestScriptSnippets.ts (+56 -0)
📝 packages/hoppscotch-js-sandbox/src/types/index.ts (+1 -0)
📝 packages/hoppscotch-js-sandbox/src/web/pre-request/index.ts (+112 -43)
📝 packages/hoppscotch-js-sandbox/src/web/pre-request/worker.ts (+110 -18)
📝 packages/hoppscotch-js-sandbox/src/web/test-runner/index.ts (+70 -43)
📝 packages/hoppscotch-js-sandbox/src/web/test-runner/worker.ts (+101 -22)

📄 Description

  • Bind fetch API to web worker context
  • Add fetch to both globalThis and self objects
  • Ensures fetch is available in pre-request scripts

Closes #5410 #3305


Summary by cubic

Adds fetch support in pre-request and test scripts by running scripts that call fetch inside a web worker and binding fetch to both globalThis and self. This enables reliable HTTP calls in scripts with cleaner logging.

  • New Features

    • Auto-detect fetch usage and execute scripts in a web worker.
    • Bind fetch to globalThis and self; forward console logs to the main thread.
    • Add pre-request script snippets showing auth token fetch and data fetch.
  • Refactors

    • Preserve temp environment variables across sandbox contexts.
    • Add timeout and cleanup to FaradayCage to avoid hanging executions.
    • Improve error messages for unsupported import/export syntax in scripts.

Written for commit 9bd264c723. Summary will update automatically on new commits.


🔄 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/5594 **Author:** [@HuynhTuanWD](https://github.com/HuynhTuanWD) **Created:** 11/18/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/support-fetch-prescript` --- ### 📝 Commits (1) - [`9bd264c`](https://github.com/hoppscotch/hoppscotch/commit/9bd264c7232a817547cfa116bc33b0ae51b94635) feat: add fetch support in pre-request scripts (#5410) ### 📊 Changes **6 files changed** (+450 additions, -126 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/src/helpers/preRequestScriptSnippets.ts` (+56 -0) 📝 `packages/hoppscotch-js-sandbox/src/types/index.ts` (+1 -0) 📝 `packages/hoppscotch-js-sandbox/src/web/pre-request/index.ts` (+112 -43) 📝 `packages/hoppscotch-js-sandbox/src/web/pre-request/worker.ts` (+110 -18) 📝 `packages/hoppscotch-js-sandbox/src/web/test-runner/index.ts` (+70 -43) 📝 `packages/hoppscotch-js-sandbox/src/web/test-runner/worker.ts` (+101 -22) </details> ### 📄 Description - Bind fetch API to web worker context - Add fetch to both globalThis and self objects - Ensures fetch is available in pre-request scripts Closes #5410 #3305 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds fetch support in pre-request and test scripts by running scripts that call fetch inside a web worker and binding fetch to both globalThis and self. This enables reliable HTTP calls in scripts with cleaner logging. - **New Features** - Auto-detect fetch usage and execute scripts in a web worker. - Bind fetch to globalThis and self; forward console logs to the main thread. - Add pre-request script snippets showing auth token fetch and data fetch. - **Refactors** - Preserve temp environment variables across sandbox contexts. - Add timeout and cleanup to FaradayCage to avoid hanging executions. - Improve error messages for unsupported import/export syntax in scripts. <sup>Written for commit 9bd264c7232a817547cfa116bc33b0ae51b94635. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:44:11 +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#5275
No description provided.