"Issue" in RED.util.cloneMessage?

I have the (strong) impression there's an "issue" in RED.util.cloneMessage. I've intentionally put those brackets around the word issue as most users won't get in touch with it ever, yet ...

Observation:
RED.util.cloneMessage wrongly changes weak arrays when cloning a message. In detail, weak ( == empty) array elements receive the value undefined during clone operation.

Analysis:
RED.util.cloneMessage forwards the message object to _.cloneDeep (lodash) to perform the clone operation. Surprisingly, there's evidence that _.cloneDeep wrongly applies undefined to empty elements:

import * as _ from 'lodash';

// create a weak array, just fill index 3:
let x = new Array(5);
x[3] = 42;

console.log("Original array:")
x.forEach( (xx, i) => console.log(`${i}: ${xx}`));
console.log("");

console.log("Array after _.cloneDeep:")
let y = _.cloneDeep(x);
y.forEach( (xx, i) => console.log(`${i}: ${xx}`));
console.log("");

console.log("Array after structuredClone:")
let z = structuredClone(x);
z.forEach( (xx, i) => console.log(`${i}: ${xx}`));

output:

There was a pull request (in 2023) to address this issue - yet, despite merged, it looks like those changes got lost due to whatever reason...

Possible fix:
As you can see, structuredClone clones the array correctly. Most probably, it should be mature enough to act as drop-in replacement for _.cloneDeep. It's a one-liner fix...

Any comments?

There are gaps & limitations in every JS cloning method, including structuredClone(), mostly around properties which need to be serialized and then de-serialized.
You need to analyze the type of objects you wish to clone: deep or shallow, do they have function members? external bindings/context? is there a risk of circular references? etc.
Then you can select the cloning method that suits you (..., assign, structuredClone, JSON stringify/parse etc.)

I built a node for dashboard 2, and encountered many issues with standard cloning methods, so had to write my own cloning function (recursive JS. Not a big deal).

Writing a "customized" cloning function might not be a be deal - but here we're talking about a topic within a function called million times a day, deep in the core of Node-RED. I'd prefer it works flawlessly for JS standard features...