postman.setNextRequest(null) is not stopping runner(solved - user error)

Link to public collection to run the demo: https://www.getpostman.com/collections/2478d8a33af312c37da6

My question: how to stop runner if the runner stops in the middle of a set of requests?

Details (like screenshots):
The script found in the Demo Setup request creates a closure with an array of jobs that are enabled or disabled. Requests are in this order in the collection: Setup Job, First Request, Second Request, Third Request.
Current demo is setup to run the Setup Job then Second Request and then stop using postman.setNextRequest(null).

This is the output:

How I found the problem: when I run the setup above, it is observed that these requests run: Setup Job, Second Request, Third Request. Third Request is not supposed to run because it is disabled. In this case, runNext does skip the Third Request but for some reason the runner keeps on executing.

I’ve already tried: not sure if there is a problem in my script but according to the output, postman.setNextRequest(null) is called after Second Request. I am not aware of other things to try but the expectation is that the run should end if postman.setNextRequest(null) is set.

1 Like