# Variables not being set for 'failed' or 'cancelled' run

**URL:** <https://community.postman.com/t/variables-not-being-set-for-failed-or-cancelled-run/44986>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [March 10, 2023, 10:02am UTC](https://community.postman.com/t/variables-not-being-set-for-failed-or-cancelled-run/44986 "2023-03-10T10:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgreen65](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@dgreen65](https://community.postman.com/u/dgreen65)\
**Post date:** [March 10, 2023, 10:02am UTC](https://community.postman.com/t/variables-not-being-set-for-failed-or-cancelled-run/44986/1 "2023-03-10T10:02:52Z")

</div>

Hi all,

I’m getting an intermittent issue with variables not being set and wonder if anyone has come across this.

I have a standard collection and during the run, some of the early tests write a variable (doesn’t matter which type, collection, environment etc) which is used in later tests. If I run the tests individually, the variable is written fine. If I run the test set as a collection, and for whatever reason it doesn’t complete, either because of a failure or I terminate the run, they are not always written.

Anyone seen this ? I’m running v9.21.5

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![arlem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/arlem/32/3078_2.png) [@arlem](https://community.postman.com/u/arlem)\
**Post date:** [March 10, 2023, 3:42pm UTC](https://community.postman.com/t/variables-not-being-set-for-failed-or-cancelled-run/44986/2 "2023-03-10T15:42:56Z")

</div>

Hey @dgreen65

This is the expected behaviour, the variables are written at the end of the run (and only if you select the `Keep variable values` options before running the collection), so if you run quits unexpectedly it won’t write them.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [September 17, 2023, 9:57am UTC](https://community.postman.com/t/variables-not-being-set-for-failed-or-cancelled-run/44986/3 "2023-09-17T09:57:24Z")

</div>

Closed on September 17, 2023, 9:57am UTC

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