When we retrieving an Buffer object via get - a Buffer is always returned; in this example, a Uint8Array is returned causing issues downstreams when working with the response
We believe the reason is due to this line, where Buffers can be casted to Uint8Arrays under the hood.
As a workaround we explicitly check that we are returned a Buffer and if not, create one from the returned object:
const potentialBuffer = lmdb.get(key)
if (potentialBuffer) {
return Buffer.from(value.buffer);
}
Environment:
NodeJS
:18.17.1
lmdb
:2.8.5
Example:
Expectations:
Buffer
object viaget
- aBuffer
is always returned; in this example, aUint8Array
is returned causing issues downstreams when working with the responseWe believe the reason is due to this line, where
Buffers
can be casted toUint8Arrays
under the hood.As a workaround we explicitly check that we are returned a
Buffer
and if not, create one from the returned object: