[GH-ISSUE #4788] [bug]: Pre request scripts don't concurrently update global variables when request is pending #1795

Open
opened 2026-03-16 21:46:22 +03:00 by kerem · 0 comments
Owner

Originally created by @evanqhuang on GitHub (Feb 25, 2025).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4788

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Testing a workflow where the request hangs until a promise is completed. It seems like the environment variables aren't updated concurrently by the pre request scripts. So when I go to execute a separate request that uses an environment variable updated by the pre request scripts of the first (pending) request, the variable has not been updated.

I would expect the behavior of pre request scripts to be executed fully before the request is sent, so that environment variables are set and updated before the request is sent, and so any following requests can use the updated environment variable even if the preceding request hasn't completed.

Steps to reproduce

In my pre request script I have

// Set random number variable
const min = 1
const max = 1000
const randomArbitrary = Math.random() * (max - min) + min
pw.env.set("workflow_id", randomArbitrary.toString());

to set a random workflow_id in the global environment variables. I've verified that the workflow_id is populated correctly in the initial request. The endpoint must hang so that the request isn't completed.

In a separate request when I try to use it in the url parameters <<workflow_id>> is still blank.

Environment

Production

Version

Cloud

Originally created by @evanqhuang on GitHub (Feb 25, 2025). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4788 ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current behavior Testing a workflow where the request hangs until a promise is completed. It seems like the environment variables aren't updated concurrently by the pre request scripts. So when I go to execute a separate request that uses an environment variable updated by the pre request scripts of the first (pending) request, the variable has not been updated. I would expect the behavior of pre request scripts to be executed fully before the request is sent, so that environment variables are set and updated before the request is sent, and so any following requests can use the updated environment variable even if the preceding request hasn't completed. ### Steps to reproduce In my pre request script I have ``` // Set random number variable const min = 1 const max = 1000 const randomArbitrary = Math.random() * (max - min) + min pw.env.set("workflow_id", randomArbitrary.toString()); ``` to set a random workflow_id in the global environment variables. I've verified that the `workflow_id` is populated correctly in the initial request. The endpoint must hang so that the request isn't completed. In a separate request when I try to use it in the url parameters `<<workflow_id>>` is still blank. ### Environment Production ### Version Cloud
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#1795
No description provided.