# Delay test result until process completes

**URL:** <https://community.postman.com/t/delay-test-result-until-process-completes/6260>\
**Category:** Help Hub\
**Tags:** tests, asynchronous, wait\
**Created:** [July 2, 2019, 9:14pm UTC](https://community.postman.com/t/delay-test-result-until-process-completes/6260 "2019-07-02T21:14:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpack](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@hpack](https://community.postman.com/u/hpack)\
**Post date:** [July 2, 2019, 9:14pm UTC](https://community.postman.com/t/delay-test-result-until-process-completes/6260/1 "2019-07-02T21:14:23Z")

</div>

I use a POST request to initiate a flow which calls several APIs. The POST request returns a progress URL in its body, and that progress URL has a JSON key, “state”, which indicates whether all the APIs have been called successfully.

The value of “state” is initially “RETRY”, but after a minute or two resolves to either “SUCCESS” or “FAILURE”. As such, a test that immediately checks whether “state” === “SUCCESS” will always fail.

I have tried things such as setTimeout to try and delay the check to “state”, and have also tried do/while loops where “state” is checked repeatedly until it resolves to either “SUCCESS” or “FAILURE”.

Both of these types of approaches ends up crashing my Postman app; at best, I receive an error message: “There was an error in evaluating the test script: Error: sandbox: execution interrupted, bridge disconnecting.”.

I appreciate any help anyone can offer. I’m running the latest Postman App on a Windows 10 PC.

Thank you!

---

<div class="post-metadata">

**Author:** ![postman-paul540](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/postman-paul540/32/149_2.png) [@postman-paul540](https://community.postman.com/u/postman-paul540)\
**Post date:** [July 2, 2019, 9:40pm UTC](https://community.postman.com/t/delay-test-result-until-process-completes/6260/2 "2019-07-02T21:40:07Z")

</div>

Hey @hpack, welcome to the Postman community.

> [@Wait for data to exist - (Waiting for database/cloud to return the latest version of the data)](https://community.postman.com/t/wait-for-data-to-exist-waiting-for-database-cloud-to-return-the-latest-version-of-the-data/3219):
>
> Hi all, I’ve been away from Postman for a year, so forgive me if this action is easily supported/ been asked before… Basically, I have a POST/PUT request that creates data. I am then using a GET to confirm the data entry exists and all the relevant data is there. However, sometimes the data is not present when calling the GET straight after the previous request. This is more prevalent in the runner as the data entry isn’t available at that time. I tried getting around this using a ‘dirty’ …

I posted the above thread a while ago, let me know if it helps you out at all.

From what I remember, I believe I’m using a POST request to create a customer, and then using a GET customers endpoint to confirm if that customer now exists. But it may take a few seconds for that customer to exist, this scenario will obviously fail when the test is ran via the collection runner.

So I basically, keep hitting the GET customers endpoint x times until the record is there. If after X times the customer record is still now there then we go “Ok, we’ve tried enough times now and the customer record is still not there. Let’s mark this as failed and move onto the next request”

Hopefully the thread can give you some value even though my solution sounds a little messy/hacky 🙂
