Unpacking a buffer produces string #45

jacwright opened this Issue May 13, 2013 · 3 comments


None yet

2 participants


A buffer goes into msgpack, a string comes back out. It should be a buffer object when it is unpacked.

var buffer = fs.readFileSync("avatar.png")
var person = {
name: "Bob",
avatar: buffer

person = msgpack.unpack(msgpack.pack(person))

console.log(typeof person.avatar) // you get "string", should be a Buffer

The line in msgpack.cc that does this is:

return String::New(mo->via.raw.ptr, mo->via.raw.size);

I'm not a C coder nor do I know anything about c-lib bindings with v8, otherwise this would be a pull request instead. Could you please fix this?


You may want to attach this to:

At some point we need to just go a direction.


Ah, didn't even realize MSGPACK_OBJECT_RAW was being used for multiple types. I'll go comment on the other issue, but definitely stick with string and don't purport to support buffers, since really you can't. That will allow the developer a choice of encoding and decoding with base64 instead of having them find out the hard way that buffers aren't really supported.


Going to close this issue so that we just have issue #6 on the topic.

@godsflaw godsflaw closed this Jun 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment