Buffer Parser - msg.originalPayload

I have been using the Buffer Parser node and had and came across a situation where I wanted to pass the original buffer on to another parser so I assumed the "originalPayload" buffer in the output msg would be what to use. I did a Swap 16 in the parser and the originalPayload buffer changed to the swapped buffer. Was the intention of msg.originalPayload to be a copy of the original buffer that was input? There is also msg.buffer in the output msg that is the same as msg.originalPayload.

Unfortunately, the assignment to opticalPayload is a reassignment of the original payload (not a clone) & thus it is merely a reference to the original (so it really the same object as payload)

In hindsight, it could(should) be a clone.

I'll fix it soon. In the meantime, you could put a function node before...

msg._payload = RED.util.cloneMessage(msg.payload)

That depends on the input. The buffer parser accepts string or integer array too but msg.buffer is always a buffer equivalent of the input data regardless of input type. It's for passing to next node. Should probably be a clone if the input is a buffer (same as originalPayload) to avoid same issue.

1 Like

Thanks Steve...Always appreciate what you do!

2 Likes

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