Request object deleted

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?

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).

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.

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.

I would recommend using fs-ops-dir from 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.

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.

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