# Live stream about pluggable message routing: some questions

**URL:** https://discourse.nodered.org/t/live-stream-about-pluggable-message-routing-some-questions/30508
**Category:** Core Development
**Created:** [21 July 2020 21:23 UTC](https://discourse.nodered.org/t/live-stream-about-pluggable-message-routing-some-questions/30508 "2020-07-21T21:23:10Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [25 July 2020 13:03 UTC](https://discourse.nodered.org/t/live-stream-about-pluggable-message-routing-some-questions/30508/12 "2020-07-25T13:03:00Z")

</div>

> [@cinhcet](#):
>
> This goes a bit off-topic now

Nick has been so kind to mention the cloning in the design document, so IMHO we are still on topic 😉

> [@cinhcet](#):
>
> if the node itself could specify the cloning behavior if its is output is connected

Don't think that would solve the problem, since the message (containing an object which need custom cloning) will traverse through the flow through all kind of nodes. And those nodes are not aware of the cloning requirements of the messages passing through them. Moreover a message can contain objects from other nodes also, which might need other special cloning treatment. Nick's router however is nicely positioned between all nodes, so it could do the job. As I said before, he has created a very nice design!!

Will try not to go into too much detail (because this feature is only in an early design status), but that _ **really** _ hurts to be honest 😱. Currently msg cloning in Node-RED simply [calls](https://github.com/amodelbello/node-red/blob/master/packages/node_modules/@node-red/util/lib/util.js#L90) the _ **Lodash cloneDeep** _ function. Suppose we have multiple cloning hook handlers in the future:

- I develop a custom cloning hook handler to clone Opencv matrix objects.
- But another custom cloning hook handler implement custom cloning of another type of objects.
- And so on ...

And all those objects can be available in one single msg! I assume that a cloning hook could e.g. call the Lodash [cloneDeepWith](https://lodash.com/docs/#cloneDeepWith) function (instead of cloneDeep) which accepts a _customizer_ parameter:

```auto
function customizer(value) {
  // Ask each custom clone hook handler whether it wants to custom clone this (nested) msg property
  if (...) {
    return value.cloneNode(true);
  }
}
var clonedMsg = lodash.cloneDeepWith(msg, customizer);

```

But now I'm going to stop brainstorming, otherwise I most certainly will be banned from the Node-RED community 😉

---

_[View the full topic](https://discourse.nodered.org/t/live-stream-about-pluggable-message-routing-some-questions/30508)._
