# Context.get stoped working

**URL:** <https://discourse.nodered.org/t/context-get-stoped-working/5663>\
**Category:** General\
**Created:** [11 December 2018 06:46 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663 "2018-12-11T06:46:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![toogooda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/toogooda/32/4447_2.png) [@toogooda](https://discourse.nodered.org/u/toogooda)\
**Post date:** [11 December 2018 06:46 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/1 "2018-12-11T06:46:02Z")

</div>

Hi All,

I had used a simple function to check if the value of the water tank had changed before sending a slack notification. was all working then one day started sending it every time like it was not saving the value.  
I tried changing the variable name from ('Tank1') to (TankOne') deployed and all working again.  
Any ideas why, I do get many messages is there a limit to how many times you can save a context variable?

var tank1=context.get('tankOne') ||0;  
if (msg.payload != tank1){  
context.set('tankOne',msg.payload);  
return msg;  
}else{  
msg.payload="Same";  
return msg  
}

I did debugs and it had stoped sending "Same" and always sent on the msg.payload.

---

<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:** [11 December 2018 09:26 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/2 "2018-12-11T09:26:23Z")

</div>

What change did you make to the flow just before the issue occurred?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 December 2018 11:52 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/3 "2018-12-11T11:52:08Z")

</div>

Try this and see from the debug pane what is going on

```auto
var tank1=context.get('tankOne') ||0;
node.warn("payload: " + msg.payload +"tank1: " + tank1);
if (msg.payload != tank1){
  node.warn("Different");
  context.set('tankOne',msg.payload);
  return msg;
}else{
  node.warn("Same");
  msg.payload="Same";
  return msg
}

```

---

<div class="post-metadata">

**Author:** ![toogooda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/toogooda/32/4447_2.png) [@toogooda](https://discourse.nodered.org/u/toogooda)\
**Post date:** [12 December 2018 01:25 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/4 "2018-12-12T01:25:26Z")

</div>

@zenofmud I think I had moved a flow from that worspace to another tab (sorry if that terminology is not correct) via cut and paste then deploy. These nodes that modes were not part of this flow but were on the same tab.  
I may have also removed the degbugs.

---

<div class="post-metadata">

**Author:** ![toogooda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/toogooda/32/4447_2.png) [@toogooda](https://discourse.nodered.org/u/toogooda)\
**Post date:** [12 December 2018 01:28 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/5 "2018-12-12T01:28:01Z")

</div>

Hi Colin, when I changed  
tank1=context.get('tank1')

to

`tank1=context.get('tankOne')`

and the set it fixed it, as stated above but I don't know why it was broken or why changing a variable name would fix it.

I will try out the node.warn though, is it similar to a debug?

---

<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:** [12 December 2018 01:32 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/6 "2018-12-12T01:32:21Z")

</div>

It would be my guess that if everything was working and then you moved some flows and then it stopped working, something you moved was the root of your issue.

But since it is now working, I would not spend too much time on rying to figure out why if you can't recreate it.

---

<div class="post-metadata">

**Author:** ![toogooda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/toogooda/32/4447_2.png) [@toogooda](https://discourse.nodered.org/u/toogooda)\
**Post date:** [12 December 2018 04:19 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/7 "2018-12-12T04:19:33Z")

</div>

I would agree except they were unlelated and I didn't undo any of it to fix it which makes me think there is some sort or NodeRed bug around context variables.  
Its about stability, the result was many people being spamed in slack and I would like to make sure it doesn't happen again. I could clearly prove before changing the variable name that I did a save and 5 seconds later when retrieving it, it was back to default.  
I will try changing it back to that old variable name.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 December 2018 21:39 UTC](https://discourse.nodered.org/t/context-get-stoped-working/5663/8 "2018-12-12T21:39:27Z")

</div>

> [@toogooda](#):
>
> I will try out the node.warn though, is it similar to a debug?

Try it and see what it does.
