setNextRequest is undefined?

There is a strange issue Iโ€™m getting when running a collection using newman.

This one request has a retry mechanism in its post-script

if (response.id == null)
{
    let retryCounter = pm.environment.get("retryCounter")
    let currentRun = pm.environment.get("currentRun");

    if (parseInt(currentRun) <= parseInt(retryCounter))
    {
        pm.execution.setNextRequest("userTask - personal data 1")
    }
    else{
        
        pm.execution.setNextRequest(null)
        throw new Error("Polling unsucessful. ID is null or same as in previous step")
    }
    pm.environment.set("currentRun", parseInt(currentRun) + 1)
}
else
{
    
    pm.execution.setNextRequest("Submit - personal data")
}

But the problem Iโ€™m getting is that newman reports a โ€œtype-script error in test scriptโ€
Upon looking at the newman report I see

Cannot read properties of undefined (reading 'setNextRequest')

Seems setNextRequest is not available from an if loop? So it seemsโ€ฆwhy?

Hey @aviation-observer-43 :wave:

Which version of Newman are you running this against?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.