# Global var is persisting between deploy

**URL:** <https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015>\
**Category:** General\
**Created:** [27 June 2024 18:55 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015 "2024-06-27T18:55:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thalesmaoa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thalesmaoa/32/17067_2.png) [@thalesmaoa](https://discourse.nodered.org/u/thalesmaoa)\
**Post date:** [27 June 2024 18:55 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015/1 "2024-06-27T18:55:21Z")

</div>

Hi there, I can't understand if this is a new behaviour. I create a global object var. After deploy it is not being erased.

Setting are default.

```auto
27 Jun 15:49:00 - [info] Node-RED version: v4.0.0
27 Jun 15:49:00 - [info] Node.js version: v20.14.0
27 Jun 15:49:00 - [info] Linux 6.9.3-76060903-generic x64 LE
27 Jun 15:49:01 - [info] Loading palette nodes
27 Jun 15:49:01 - [info] Dashboard version 3.6.5 started at /ui
27 Jun 15:49:01 - [info] Settings file : /data/settings.js
27 Jun 15:49:01 - [info] Context store : 'default' [module=memory]

``
```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 June 2024 19:28 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015/2 "2024-06-27T19:28:49Z")

</div>

It should remain over a deploy because it is in memory and the memory is is still there over a deploy. If you stop/start NR then the variable will be removed.

---

<div class="post-metadata">

**Author:** ![thalesmaoa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thalesmaoa/32/17067_2.png) [@thalesmaoa](https://discourse.nodered.org/u/thalesmaoa)\
**Post date:** [27 June 2024 19:39 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015/3 "2024-06-27T19:39:58Z")

</div>

That makes sense. I thought that it wipe out after a deploy. Any suggestion to clean memory after a deploy?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [27 June 2024 19:42 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015/4 "2024-06-27T19:42:39Z")

</div>

You can use an inject node, set it to "inject once after 0.1s", add a change node and set the global variable to nothing, or delete it.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fca29a911e6b9002a61ef5d6307e77fff858e651.png)

Note that this will require your deploy method to be set to modified flows (if it lives on the same flow) or full deploy.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 July 2024 19:43 UTC](https://discourse.nodered.org/t/global-var-is-persisting-between-deploy/89015/5 "2024-07-11T19:43:37Z")

</div>

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