postman-app-support icon indicating copy to clipboard operation
postman-app-support copied to clipboard

Environment Variables that have been updated while Websocket opened, are not available to Websocket requests

Open ctataryn opened this issue 8 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the tracker for existing similar issues and I know that duplicates will be closed

Describe the Issue

Have an issue where an environment variable is updated while a WebSocket request is still open. The value of that updated variable is not available to the Websocket until the websocket is disconnected and reconnected.

Steps To Reproduce

I have the following setup:

  1. A REST request that POSTs to an endpoint /oauth/token
    • The request returns an access_token in a json response
    • A post-res script is setup like so:
      let response = pm.response.json();
      let token = response.access_token;
      pm.environment.set("token", token );
      
  2. A Websocket request is initiated
    • a message is sent with the following format:
      {
         "messageType": "tp:AuthRequest",
         "token": "{{token}}"
      }
      
  3. The {{token}} is sent in the Websocket request
  4. If you were re-execute #1 to get a new token, then re-execute #2, the websocket request would use the token from the first time you had executed #1, not the subsequent time.
  5. If you disconnect the Websocket, then reconnect it and re-issue the request from #2, then it'll use the updated token from the second time you had executed #1

Screenshots or Videos

No response

Operating System

Windows

Postman Version

11.38.2

Postman Platform

Postman App

User Account Type

Signed In User

Additional Context?

No response

ctataryn avatar Mar 27 '25 16:03 ctataryn