# Buffer Parser - msg.originalPayload

**URL:** <https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125>\
**Category:** Industrial\
**Created:** [5 March 2021 21:43 UTC](https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125 "2021-03-05T21:43:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![djpjd](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@djpjd](https://discourse.nodered.org/u/djpjd)\
**Post date:** [5 March 2021 21:43 UTC](https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125/1 "2021-03-05T21:43:04Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad66ad536c959b494542ba31d60f651245b59235.png)

---

<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:** [5 March 2021 23:01 UTC](https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125/2 "2021-03-05T23:01:23Z")

</div>

> [@djpjd](#):
>
> Was the intention of msg.originalPayload to be a copy of the original buffer that was input

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

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

```

> [@djpjd](#):
>
> There is also msg.buffer in the output

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.

---

<div class="post-metadata">

**Author:** ![djpjd](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@djpjd](https://discourse.nodered.org/u/djpjd)\
**Post date:** [15 March 2021 12:31 UTC](https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125/3 "2021-03-15T12:31:21Z")

</div>

Thanks Steve...Always appreciate what you do!

---

<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:** [14 May 2021 12:32 UTC](https://discourse.nodered.org/t/buffer-parser-msg-originalpayload/42125/4 "2021-05-14T12:32:07Z")

</div>

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