Nested `Buffer` objects don't serialize correctly
Opened this issue · 1 comments
aabtop commented
If I cache data that contains a nested Buffer
object, such as [Buffer, string]
, then inside of formatValue()
the Buffer.isBuffer(val)
check returns false and we fall into the JSON.stringify(val)
path:
memcache-plus/lib/connection.js
Lines 70 to 76 in e3662fe
And this results in a JSON string that, when parsed, produces an object that looks like:
[
{
type: "Buffer",
data: "...",
},
string
]
which of course is not the same shape as the [Buffer, string]
object that was originally registered, which is I believe a bug.
aabtop commented
Perhaps something like https://www.npmjs.com/package/msgpackr could work better than JSON.stringify()
here?