I made a flow to a chatbot on node-red using the IBM cloud AI through http connections and I have the following problem, when sending simultaneous messages in different chats/accounts, this error occurs: "Error: Cannot set headers after they are sent to the client". I know it's related to the request that it can't be overridden. But what would be the way to have multiple devices accessing the same flow without interfering with the request already in progress?
I'm simulating sending messages through facebook messenger and instagram
thanks for the time
The last change node implies you are stashing the msg.res
field somewhere and putting it back.
I'm guessing you are using the same context variable to do this so it's getting overwritten by the second invocation, so both events try to respond on the last msg.res
and the second one fails because they can only be used once.
You shouldn't need to do this if all the nodes in the flow behave properly and don't discard msg
properties. If there is a node discarding properties then you should raise an issue with it's author to get it fixed.
In the meantime you need to make sure each invocation keeps track of it's own msg.res
which may mean storing it under a unique id (possibly msg._id
but if a node is discarding properties this might also change) to they all respond to the correct session.