# Different behaviour in Collection Runner vs. Newman

**URL:** <https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914>\
**Category:** Help Hub\
**Created:** [June 14, 2019, 12:11pm UTC](https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914 "2019-06-14T12:11:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrissbaumann](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/chrissbaumann/32/5521_2.png) [@chrissbaumann](https://community.postman.com/u/chrissbaumann)\
**Post date:** [June 14, 2019, 12:11pm UTC](https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914/1 "2019-06-14T12:11:15Z")

</div>

Hi all,

my general workflow (simplified) within a collection is:

1. Create something
2. Query certain things

Problem is, that creation sometimes fails, due to timeouts, environment not being available, you-name-it, so I want to give it a retry, especially when running the collections in Jenkins via newman.

So I came up with some Javascript in the testtab of my very first request:

```
if (!pm.environment.get("collection_tries")) {
    pm.environment.set("collection_tries", 1);
}
if ((pm.response.code != 201) && (pm.environment.get("collection_tries") < 3)) {
var tries = parseInt(pm.environment.get("collection_tries"), 10);
pm.environment.set("collection_tries", tries + 1);
     setTimeout(function() {}, 5000);
     postman.setNextRequest(request.name);
 } else {
     pm.environment.unset("collection_tries");
   // my tests
}

```

This is working perfectly fine in the Collectionrunner.  
But when I execute it via Newman, I always get “500 URL Open error”.

Any ideas what is causing this?

Many thanks in advance,  
Christian

PS.: How can I format that code example properly?! :-o

---

<div class="post-metadata">

**Author:** ![vdespa](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vdespa/32/2770_2.png) [@vdespa](https://community.postman.com/u/vdespa)\
**Post date:** [June 15, 2019, 6:31am UTC](https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914/2 "2019-06-15T06:31:40Z")

</div>

I am not sure your problem comes directly from your code.  
Did you try using the htmlextra report and look into what was sent / received?

Maybe there is a variable in the URL / body that is not properly resolved.

---

<div class="post-metadata">

**Author:** ![chrissbaumann](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/chrissbaumann/32/5521_2.png) [@chrissbaumann](https://community.postman.com/u/chrissbaumann)\
**Post date:** [June 17, 2019, 6:36am UTC](https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914/3 "2019-06-17T06:36:16Z")

</div>

Outch! 🙈  
There´s indeed a problem in out test environment, thanks for pointing that out!

---

<div class="post-metadata">

**Author:** ![VincentD123](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vincentd123/32/1845_2.png) [@VincentD123](https://community.postman.com/u/VincentD123)\
**Post date:** [June 20, 2019, 9:38am UTC](https://community.postman.com/t/different-behaviour-in-collection-runner-vs-newman/5914/4 "2019-06-20T09:38:20Z")

</div>

> [@chrissbaumann](#):
>
> PS.: How can I format that code example properly?! :-o

````
```javascript
the code goes here
```

````

eg.

```javascript
const xyz = [1,2,3,4];
JSON.parse(`{"abc" : "is a string"}`);

```

👼
