After latest update saving variables in post-request script are not consistent anymore

Hi,

Since latest update (11.61.9) variables are not saved anymore, they are sometimes but in most cases they are not.

I can save some variables in post-request script in to collection variables, i can also verify that its saved by checking with console.log(pm.collectionVariables.get(‘someVariableName’)) at the very end of post-request script, but then after request fully ends this variable is just wiped out, i can also verify it by adding console.log(pm.collectionVariables.get(‘someVariableName’)) at the top in pre-request script of next request and console output will be empty.

Example:

Object is saved to collection variables at the end of post-request script (30)

Then at the start of pre-request script of next request same variable is empty.

image

Nothing is overwriting/resetting anywhere.

Sometimes variable is saved correctly, like after sending request 20+ times, one time it will randomly save correctly.

It was working for past 2 years+ but this week is not working anymore with no code changes.

Please help

Hey @lednik :waving_hand:t2:

Could you share the full script showing how these variables are being set during the execution?

Do you have any scripts are any other level that could be clearing these?

Im can save them in 3 different ways, noone of them arent working anymore since this week.

  1. Saving through collection’s utils class in pre-request script:

Object.prototype.utils = (pm) => {

function setVar(varName, varValue) {

    pm.collectionVariables.set(varName, varValue)

}

function getVar(varName) {

    return pm.collectionVariables.get(varName)

}

….

return {

    setVar,

    getVar,

Then in requests pre/post requests calling utils.getVar / utils.setVar

  1. Saving them directly inside of post-request script through helper methods:
    function setVar(varName, varValue){

    pm.collectionVariables.set(varName, varValue)

}

function getVar(varName){

return pm.collectionVariables.get(varName)

}

Then calling them by getVar / setVar

  1. Direct saving to collectionVariables:

pm.collectionVariables.set(‘someVariableName’, value)

pm.collectionVariables.set(‘someVariableName2’, value2)

all 3 different approaches were working before, but now none of them is consistent anymore.

Outside of this issue, I would recommend using the package library for any reusable utils that you might need to, they method you’re using is a workaround that was using before this feature was introduced.

Do you have a recording of this happening or anything so that we can see what’s happening on your side? As it’s an intermittent issue for you, it’s difficult for us to reproduce that on our side. :cry:

Its still working fine in postman Canary (Version 11.2.14-canary01, UI Version 11.2.14-ui-canary240621-0734) on same collections as in Postman app and Postman Web

I cant show collection publicly since its a work collection, is there any option to message you private with video comparison from Postman and Postman Canary ?