Context variables - how to see them

In all my flows I have one node with a context variable. Everything else is msg, with very few global variables.

From the documentation and fro previous forum posts, I understand that I should be able to see the content of this context variable by looking at the node with the context sidebar open.

But when I try it, there's nothing in the sidebar. I click on the node and nothing appears in the sidebar. I click on the node and click refresh, nothing appears. If I run the node, the context variable is definitely stored, but i can't see where to see it.

What am I missing?

How do you set the node context variables

Show us the node and any function code.

I set up the variable with

var inflightProcesses = context.get("inflightProcesses")

That "inflightProcesses" is an array. I check in it to see if a new process matches an existing one, then I add the new process to the array and set the new array back into the variable. The size of the array never gets bigger than 20. (I add the new element to the array with array.push(newElement) and use shift to delete the oldest element)

addElement(inflightProcesses, msg.newProcess)
context.set("inflightProcesses", inflightProcesses)

Everything works....I just can't inspect the contents of the context variable without doing node.warn or adding a debug node.

Click on the function node containing the code shown, the node will be highlighted red, then in the context sidebar click refresh in the node section.

Yep. That's what I do. Exactly that.

When you open the context view, do you press the refresh icon?
[edit] oops, never mind, I should have watched the video you posted

1 Like

Then show the code in the function node, in a copyable format. I think your function may be writing then deleting it.
As the get.context will return undefined, then when you set.context to undefined, the context var would be deleted, ie. undefined.
[edit] add context.set("test", "test") to the start of your function, then run the function and then check the context store in the sidebar.

At various stages I've added node.warn in the code at the top and bottom. The data is most definitely in the variable.

The context variable is a 20 element array that is used, in that node, to store the last 20 processes through the node. There's old data in the variable. It just doesn't show in the sidebar.

Add context.set("test", "test") at the very top of the function.

Make sure the function has ran (use an inject node if necessary)

do you see test variable?

Nope. And I'm setting the context variable and using it already. It's there. I can output it with node.warn()

I just can't see it via the sidebar.

As @E1cid asked, can you share a simple flow to demonstrate the issue ?

Which context variable - did you " Add context.set("test", "test") at the very top of the function." as per request?

Yes, however if the lines underneath the node.warn delete the variable, it wont show in the sidebar.

Please be explicit in your responses to avoid confusion.

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