# Flow context \[object Object\] while it exists?

**URL:** https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339
**Category:** General
**Created:** [9 March 2023 09:31 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339 "2023-03-09T09:31:41Z")
**Posts on this page:** 11
**Page:** 1

<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: [9 March 2023 09:31 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/1 "2023-03-09T09:31:41Z")

</div>

I am confused, flow context says:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e1117c8cf35517df37b39c21ba6c901fd70ef673.png)

But injecting flow.browser produces:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7eea75e5bb23fe0a23ee3c867e45adad822278dc.png)

It works, so that is great, but why is the context tab not parsing it ?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [9 March 2023 09:48 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/2 "2023-03-09T09:48:05Z")

</div>

Odd - can you pass it to a function node with:

```auto
node.warn(typeof msg.browser) // or which ever is the object from context

```

---

<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: [9 March 2023 09:55 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/3 "2023-03-09T09:55:22Z")

</div>

> [@knolleary](#):
>
> `node.warn(typeof msg.browser)`

It says it is an object

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

---

<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: [9 March 2023 10:28 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/4 "2023-03-09T10:28:46Z")

</div>

I cannot reproduce it from an inject node.

It only happens from the producing node ([webdriver](https://flows.nodered.org/node/node-red-contrib-simple-webdriver)). When I set/move it to msg payload and then to a flow var, it also becomes [object Object] in the context. Very strange. Are there any reserved keywords ?

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

Something more fishy:

Set inject node to msg.payload = flow.browser and a debug node to only display msg.payload: [object Object]  
Set debug node to complete msg object, it displays payload (correctly) as an object.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [9 March 2023 10:43 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/5 "2023-03-09T10:43:43Z")

</div>

This will be related to the type of object the webdriver node is producing which is tripping up our encoding logic when the runtime is wrapping it up to pass to the editor. It isn't a true reflection of the what is actually stored.

There are subtly different code paths around rendering the top level object (`msg`) and rendering properties (`msg.payload`) which is why you get different results.

Without digging into the code, I can't be more specific at the moment. If you wanted to raise an issue that would be helpful.

---

<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: [9 March 2023 11:05 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/6 "2023-03-09T11:05:28Z")

</div>

I could also raise the question first at the node creator.

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [9 March 2023 11:07 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/7 "2023-03-09T11:07:20Z")

</div>

I don't think they are doing anything unreasonable.

JavaScript has lots of different subtly ways of dressing up objects. We ought to be able to handle them more generally, rather than having to make special cases. I thought we had got there, but this appears to be another edge case to deal with.

---

<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: [9 March 2023 12:24 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/8 "2023-03-09T12:24:40Z")

</div>

Ok thanks, I have raised [issue 4098](https://github.com/node-red/node-red/issues/4098)

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [9 March 2023 15:51 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/9 "2023-03-09T15:51:53Z")

</div>

~~I'm not sure if this is the right answer (I'm not a pro in this area)~~

~~but you can check if there is a defined `constructor`, and unwrap it if so~~

~~EDIT  
Check if the `constructor` name is `Function` not if its undefined (as I do in the screenshot) ::~~

I was wrong, nothing to see here. 😅

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [9 March 2023 15:58 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/10 "2023-03-09T15:58:33Z")

</div>

Same happend to me in my custom nodes. When creating an object via a constructor, it would appear in the debug window as **[object object]**.  
Then I moved to creating the object via a function, and it shows properly.

```auto
function someNewObj(val1, val2) {
   return {prop1:val1, prop2:val2};
}

```

---

<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: [8 May 2023 15:58 UTC](https://discourse.nodered.org/t/flow-context-object-object-while-it-exists/76339/11 "2023-05-08T15:58:53Z")

</div>

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