# Message scope context store

**URL:** <https://discourse.nodered.org/t/message-scope-context-store/79334>\
**Category:** Feature Requests\
**Created:** [21 June 2023 08:41 UTC](https://discourse.nodered.org/t/message-scope-context-store/79334 "2023-06-21T08:41:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eslym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eslym/32/80809_2.png) [@eslym](https://discourse.nodered.org/u/eslym)\
**Post date:** [21 June 2023 08:41 UTC](https://discourse.nodered.org/t/message-scope-context-store/79334/1 "2023-06-21T08:41:48Z")

</div>

so far the context store only have node, flow and global scope, but there is some objects still might need to be pass with the message during execution but not cloneable.

the most obvious example are http request and response, what node-red currently does is having them in as `req` and `res` in message and exclude them when cloning the message object ([RED.util.cloneMessage](https://github.com/node-red/node-red/blob/5d698d66d0857e65b08be41b212b7bcafe5f8261/packages/node_modules/%40node-red/util/lib/util.js#L98)), which is not really convenience

this behavior really creates problem when writing third-party nodes for node-red

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [21 June 2023 08:58 UTC](https://discourse.nodered.org/t/message-scope-context-store/79334/2 "2023-06-21T08:58:42Z")

</div>

Hi @eslym

Is there a question or feature request here?

> [@eslym](#):
>
> this behavior really creates problem when writing third-party nodes for node-red

What behaviour (having req/res in themsg? the non cloning of req/res? other non cloneable props? ) and what problems are you having?

---

<div class="post-metadata">

**Author:** ![eslym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eslym/32/80809_2.png) [@eslym](https://discourse.nodered.org/u/eslym)\
**Post date:** [21 June 2023 11:02 UTC](https://discourse.nodered.org/t/message-scope-context-store/79334/3 "2023-06-21T11:02:29Z")

</div>

previously i was thinking maybe node red could provide a way to safely pass non-cloneable objects with message, like what node-red does to http request  
if i want making node-red to support discord interaction, then the interaction need to be pass with message, but now i found the way to do it safely `node.send({ ...msg, getInteraction: ()=> interactionObject })`, using this method can ensure the interaction object will be the same instance as it received

---

<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:** [20 August 2023 11:03 UTC](https://discourse.nodered.org/t/message-scope-context-store/79334/4 "2023-08-20T11:03:11Z")

</div>

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