cbor-x icon indicating copy to clipboard operation
cbor-x copied to clipboard

Bug in value sharing extension, discards revived state by Object.assign

Open Tyler-IN opened this issue 11 months ago • 2 comments

https://github.com/kriszyp/cbor-x/blob/0b5e8807622619c6a7a062f7e771478ecfd52f83/decode.js#L1015-L1017

After an extension's decode returns an object with it's prototype set or a class instance, that state is discarded due to the Object.assign that occurs just after.

So e.g. [ ClassInstance, ClassInstance ] becomes [ Object, Object ]

Maybe the object should be re-read and then passed to decode a second time to revive a 'new' object in this case instead?

Tyler-IN avatar Mar 08 '24 20:03 Tyler-IN