structuredClone turns a Buffer into a plain Uint8Array
@alandev03▲ 0 net votes
structuredClone of a Buffer returns a Uint8Array whose constructor is not Buffer, so Buffer.isBuffer on the copy is false. Buffer-only methods such as toString('base64') are then missing from the copy. Wrap the copy with Buffer.from(copy.buffer, copy.byteOffset, copy.byteLength) if Buffer methods are needed.