# Request object deleted

**URL:** <https://discourse.nodered.org/t/request-object-deleted/60515>\
**Category:** General\
**Created:** [29 March 2022 22:33 UTC](https://discourse.nodered.org/t/request-object-deleted/60515 "2022-03-29T22:33:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nodeautomata](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodeautomata/32/106678_2.png) [@nodeautomata](https://discourse.nodered.org/u/nodeautomata)\
**Post date:** [29 March 2022 22:33 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/1 "2022-03-29T22:33:15Z")

</div>

I'm using File Lister node. It wipes out msg.payload. I can see that, ok, whatever. But it also whacks msg.req and msg.res. I'm using a http in node and having msg.res/req get wiped causes much trouble. I tried copying it to msg.origPayload but no luck.

Anyone run into the msg.res/req being deleted issue and have a graceful solution?

---

<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:** [29 March 2022 22:42 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/2 "2022-03-29T22:42:52Z")

</div>

Hi @nodeautomata

Do you know which module the File Lister node comes from? What you describe is a bug with the node that should get reported against the module and hopefully fixed.

There are some workarounds, but they depend on your exact use case.

If you know your flow will never by triggered twice at the same time (ie overlapping requests), then you can copy `msg.req`/`msg.res` into flow context, and then reattach them to the message after the File Lister node. (The problem with this approach is that if a second request comes in whilst the first is still being handled, the values stored in flow context will be overwritten with the new request's values).

---

<div class="post-metadata">

**Author:** ![nodeautomata](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodeautomata/32/106678_2.png) [@nodeautomata](https://discourse.nodered.org/u/nodeautomata)\
**Post date:** [31 March 2022 17:03 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/3 "2022-03-31T17:03:43Z")

</div>

It's part of node-red-contrib-fs. I haven't tried putting it into a flow variable. I assume that wouldn't work much better than putting it into msg.savestuff. When I tried saving it in a different part of the message it was saved but blew chunks when I copied it back into msg.req right before the http response. There are a lot of functions and stuff in there so I don't think it can be easily copied.

For now I split the message and then use a join/merge at the end and it sort of works.

If this proves to be an issue I might try putting it into a flow variable and storing it in hash value indexed by the message id to deal with overlapping requests.

Bug, feature, often a matter of opinion. But I don't think the other nodes in this series do this.

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [31 March 2022 17:17 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/4 "2022-03-31T17:17:40Z")

</div>

It sounds like the node is creating an all new `msg` object between input and output. Under nearly all situations that is a bug and they should fix it. You really should raise this.

It really is not a feature.

---

<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:** [31 March 2022 18:18 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/5 "2022-03-31T18:18:45Z")

</div>

I would recommend using fs-ops-dir from [node-red-contrib-fs-ops](https://flows.nodered.org/node/node-red-contrib-fs-ops) package. It is well thought out package of useful file & directory nodes. I am fairly certain this node does not discard the original `msg` object.

---

<div class="post-metadata">

**Author:** ![nodeautomata](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodeautomata/32/106678_2.png) [@nodeautomata](https://discourse.nodered.org/u/nodeautomata)\
**Post date:** [2 April 2022 02:19 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/6 "2022-04-02T02:19:46Z")

</div>

After multiple rewrites for multiple reasons I used exec and find. Performance was vastly improved afterwards.

fs-ops-dir didn't seem suitable because I'm looking several layers deep for files which may or may not have variations in the name.

---

<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:** [16 April 2022 02:20 UTC](https://discourse.nodered.org/t/request-object-deleted/60515/7 "2022-04-16T02:20:46Z")

</div>

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