Giter Club home page Giter Club logo

node-msgpack's People

Contributors

bombela avatar bpot avatar crow-misia avatar dainis avatar godsflaw avatar htaox avatar matthiasg avatar maxtaco avatar mikepb avatar mog422 avatar mscdex avatar pgriess avatar rashfael avatar sdepold avatar squamos avatar tomtaylor avatar touhonoob avatar walf443 avatar xadillax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-msgpack's Issues

issues compiling for v0.3.X

Buffer has changed enough to break node-msgpack. Forced to stick to v0.2.5.

Any schedule for supporting v0.3 yet?

Eliminate duplicate `npm` registrations

Node-msgpack is registered three separate times by Peter Griess

  1. correctly as msgpack — lists versions (0.1.2, 0.1.3)
  2. incorrectly as msgpack-0.4 — semantic versioning should be handled within registration using version metadata. Version (0.1.4)
  3. unnecessarily as msgpack2 — lists versions (0.1.4, 0.1.5, 0.1.6, 0.1.7). Name change not reflected in the metadata minor version numbers, leading to confusion on why the name changed.

Proposed solution: re-publish newest versions in msgpack2 to msgpack, and remove or migrate msgpack2 and msgpack-0.4 in favor of msgpack key.

npm install msgpack doesn't work on node v0.10.28

Here is my log running npm install msgpack

npm http GET https://registry.npmjs.org/msgpack
npm http 304 https://registry.npmjs.org/msgpack
> [email protected] install /data/mongolab/node_modules/msgpack
> node-gyp rebuild
make: Entering directory `/data/mongolab/node_modules/msgpack/build'
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
In file included from ../deps/msgpack/msgpack/type/fixint.hpp:22:0,
                 from ../deps/msgpack/msgpack/type.hpp:3,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/int.hpp: In static member function 'static void msgpack::type::detail::object_char_sign<true>::make(msgpack::object&, char)':
../deps/msgpack/msgpack/type/int.hpp:102:22: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
     : o.type = type::POSITIVE_INTEGER, o.via.u64 = v;
                      ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, signed char)':
../deps/msgpack/msgpack/type/int.hpp:206:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, short int)':
../deps/msgpack/msgpack/type/int.hpp:209:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, int)':
../deps/msgpack/msgpack/type/int.hpp:212:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, long int)':
../deps/msgpack/msgpack/type/int.hpp:215:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, long long int)':
../deps/msgpack/msgpack/type/int.hpp:218:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
In file included from ../deps/msgpack/msgpack/type.hpp:3:0,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int8)':
../deps/msgpack/msgpack/type/fixint.hpp:118:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
In file included from ../deps/msgpack/msgpack/type.hpp:3:0,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int16)':
../deps/msgpack/msgpack/type/fixint.hpp:121:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int32)':
../deps/msgpack/msgpack/type/fixint.hpp:124:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int64)':
../deps/msgpack/msgpack/type/fixint.hpp:127:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
../deps/msgpack/unpack.c: In function 'template_callback_root':
../deps/msgpack/unpack.c:59:1: warning: missing initializer for field 'type' of 'msgpack_object' [-Wmissing-field-initializers]
 { msgpack_object o = {}; return o; }
 ^
In file included from ../deps/msgpack/msgpack/unpack.h:22:0,
                 from ../deps/msgpack/unpack.c:18:
../deps/msgpack/msgpack/object.h:76:22: note: 'type' declared here
  msgpack_object_type type;
                      ^
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  AR(target) Release/obj.target/deps/msgpack/msgpack.a
  COPY Release/msgpack.a
  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
  SOLINK_MODULE(target) Release/obj.target/msgpackBinding.node
  SOLINK_MODULE(target) Release/obj.target/msgpackBinding.node: Finished
  COPY Release/msgpackBinding.node
make: Leaving directory `/data/mongolab/node_modules/msgpack/build'
npm ERR! peerinvalid The package winston does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants winston@>=0.5.0 <0.7.1
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "msgpack"
npm ERR! cwd /data/mongolab
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /data/mongolab/npm-debug.log
npm ERR! not ok code 0
[ root@dd9e6a72fe6b:/data/mongolab ]$ vim /data/mongolab/npm-debug.log
[ root@dd9e6a72fe6b:/data/mongolab ]$ vim /data/mongolab/npm-debug.log ^C^C
[ root@dd9e6a72fe6b:/data/mongolab ]$ rm /data/mongolab/npm-debug.log
rm: remove regular file '/data/mongolab/npm-debug.log'? ^[OA^H^H^C
[ root@dd9e6a72fe6b:/data/mongolab ]$ rm /data/mongolab/npm-debug.log
rm: remove regular file '/data/mongolab/npm-debug.log'? y
[ root@dd9e6a72fe6b:/data/mongolab ]$ npm install msgpack
npm http GET https://registry.npmjs.org/msgpack
npm http 304 https://registry.npmjs.org/msgpack
> [email protected] install /data/mongolab/node_modules/msgpack
> node-gyp rebuild
make: Entering directory `/data/mongolab/node_modules/msgpack/build'
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
In file included from ../deps/msgpack/msgpack/type/fixint.hpp:22:0,
                 from ../deps/msgpack/msgpack/type.hpp:3,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/int.hpp: In static member function 'static void msgpack::type::detail::object_char_sign<true>::make(msgpack::object&, char)':
../deps/msgpack/msgpack/type/int.hpp:102:22: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
     : o.type = type::POSITIVE_INTEGER, o.via.u64 = v;
                      ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, signed char)':
../deps/msgpack/msgpack/type/int.hpp:206:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, short int)':
../deps/msgpack/msgpack/type/int.hpp:209:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, int)':
../deps/msgpack/msgpack/type/int.hpp:212:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, long int)':
../deps/msgpack/msgpack/type/int.hpp:215:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
../deps/msgpack/msgpack/type/int.hpp: In function 'void msgpack::operator<<(msgpack::object&, long long int)':
../deps/msgpack/msgpack/type/int.hpp:218:76: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v : o.type = type::POSITIVE_INTEGER, o.via.u64 = v; }
                                                                            ^
In file included from ../deps/msgpack/msgpack/type.hpp:3:0,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int8)':
../deps/msgpack/msgpack/type/fixint.hpp:118:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
In file included from ../deps/msgpack/msgpack/type.hpp:3:0,
                 from ../deps/msgpack/msgpack/object.hpp:418,
                 from ../deps/msgpack/object.cpp:18:
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int16)':
../deps/msgpack/msgpack/type/fixint.hpp:121:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int32)':
../deps/msgpack/msgpack/type/fixint.hpp:124:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
../deps/msgpack/msgpack/type/fixint.hpp: In function 'void msgpack::operator<<(msgpack::object&, msgpack::type::fix_int64)':
../deps/msgpack/msgpack/type/fixint.hpp:127:88: warning: enumeral and non-enumeral type in conditional expression [enabled by default]
  { v.get() < 0 ? o.type = type::NEGATIVE_INTEGER, o.via.i64 = v.get() : o.type = type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
                                                                                        ^
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
../deps/msgpack/unpack.c: In function 'template_callback_root':
../deps/msgpack/unpack.c:59:1: warning: missing initializer for field 'type' of 'msgpack_object' [-Wmissing-field-initializers]
 { msgpack_object o = {}; return o; }
 ^
In file included from ../deps/msgpack/msgpack/unpack.h:22:0,
                 from ../deps/msgpack/unpack.c:18:
../deps/msgpack/msgpack/object.h:76:22: note: 'type' declared here
  msgpack_object_type type;
                      ^
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  AR(target) Release/obj.target/deps/msgpack/msgpack.a
  COPY Release/msgpack.a
  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
  SOLINK_MODULE(target) Release/obj.target/msgpackBinding.node
  SOLINK_MODULE(target) Release/obj.target/msgpackBinding.node: Finished
  COPY Release/msgpackBinding.node
make: Leaving directory `/data/mongolab/node_modules/msgpack/build'
npm ERR! peerinvalid The package winston does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants winston@>=0.5.0 <0.7.1
npm ERR! System Linux 3.2.0-23-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "msgpack"
npm ERR! cwd /data/mongolab
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code EPEERINVALID
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /data/mongolab/npm-debug.log
npm ERR! not ok code 0

Unpacking a buffer produces string

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

Example:
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:

case MSGPACK_OBJECT_RAW:
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?

Cannot Decode NeoVim Metadata Object

Neovim uses msgpack-rpc for plugins. In order to get all of the commands and parameters, you must send something like:

[0, 1, 0, []] //type: request, id: 1, method: 0, params: []

This returns an object that describes all of the methods. This simple example should theoretically work.

var net = require('net');
var msgpack = require('msgpack');

var conn = net.connect({path: '/tmp/neovim_unix'}, function () {
    var ms = new msgpack.Stream(conn);
    ms.addListener('msg', function(m) {
        console.log(m);
    });
    ms.send([0, 1, 0, []]);
});

The request goes out, and I get a reply, but it parses incorrectly.

[ 1,
  1,
  null,
  [ 115,
    '��classes��Buffer�Window�Tabpage�functions�\u0000A��parameters���Buffer�buffer�can_failëreturn_type�Integer�name�buffer_get_length�id\u0001��parameters���Buffer�buffer��Integer�index�can_failëreturn_type�String�name�buffer_get_line�id\u0002��parameters���Buffer�buffer��Integer�index��String�line�can_failëreturn_type�void�name�buffer_set_line�id\u0003��parameters���Buffer�buffer��Integer�index�can_failëreturn_type�void�name�buffer_del_line�id\u0004��parameters���Buffer�buffer��Integer�start��Integer�end��Boolean�include_start��Boolean�include_end�can_failëreturn_type�StringArray�name�buffer_get_slice�id\u0005��parameters���Buffer�buffer��Integer�start��Integer�end��Boolean�include_start��Boolean�include_end��StringArray�replacement�can_failëreturn_type�void�name�buffer_set_slice�id\u0006��parameters���Buffer�buffer��String�name�can_failëreturn_type�Object�name�buffer_get_var�id\u0007��parameters���Buffer�buffer��String�name��Object�value�can_failëreturn_type�Object�name�buffer_set_var�id\b��parameters���Buffer�buffer��String�name�can_failëreturn_type�Object�name�buffer_get_option�id\t��parameters���Buffer�buffer��String�name��Object�value�can_failëreturn_type�void�name�buffer_set_option�id\n��parameters���Buffer�buffer�can_failëreturn_type�Integer�name�buffer_get_number�id\u000b��parameters���Buffer�buffer�can_failëreturn_type�String�name�buffer_get_name�id\f��parameters���Buffer�buffer��String�name�can_failëreturn_type�void�name�buffer_set_name�id\r��return_type�Boolean�parameters���Buffer�buffer�name�buffer_is_valid�id\u000e��parameters���Buffer�buffer��Integer�lnum��StringArray�lines�can_failëreturn_type�void�name�buffer_insert�id\u000f��parameters���Buffer�buffer��String�name�can_failëreturn_type�Position�name�buffer_get_mark�id\u0010��parameters���Tabpage�tabpage�can_failëreturn_type�WindowArray�name�tabpage_get_windows�id\u0011��parameters���Tabpage�tabpage��String�name�can_failëreturn_type�Object�name�tabpage_get_var�id\u0012��parameters���Tabpage�tabpage��String�name��Object�value�can_failëreturn_type�Object�name�tabpage_set_var�id\u0013��parameters���Tabpage�tabpage�can_failëreturn_type�Window�name�tabpage_get_window�id\u0014��return_type�Boolean�parameters���Tabpage�tabpage�name�tabpage_is_valid�id\u0015��return_type�void�parameters���String�str�name�vim_push_keys�id\u0016��parameters���String�str�can_failëreturn_type�void�name�vim_command�id\u0017��return_type�void�parameters���String�keys��String�mode�name�vim_feedkeys�id\u0018��return_type�String�parameters���String�str��Boolean�from_part��Boolean�do_lt��Boolean�special�name�vim_replace_termcodes�id\u0019��parameters���String�str�can_failëreturn_type�Object�name�vim_eval�id\u001a��parameters���String�str�can_failëreturn_type�Integer�name�vim_strwidth�id\u001b��return_type�StringArray�parameters��name�vim_list_runtime_paths�id\u001c��parameters���String�dir�can_failëreturn_type�void�name�vim_change_directory�id\u001d��parameters��can_failëreturn_type�String�name�vim_get_current_line�id\u001e��parameters���String�line�can_failëreturn_type�void�name�vim_set_current_line�id\u001f��parameters��can_failëreturn_type�void�name�vim_del_current_line�id ��parameters���String�name�can_failëreturn_type�Object�name�vim_get_var�id!��parameters���String�name��Object�value�can_failëreturn_type�Object�name�vim_set_var�id"��parameters���String�name�can_failëreturn_type�Object�name�vim_get_vvar�id#��parameters���String�name�can_failëreturn_type�Object�name�vim_get_option�id$��parameters���String�name��Object�value�can_failëreturn_type�void�name�vim_set_option�id%��return_type�void�parameters���String�str�name�vim_out_write�id&��return_type�void�parameters���String�str�name�vim_err_write�id\'��return_type�BufferArray�parameters��name�vim_get_buffers�id(��return_type�Buffer�parameters��name�vim_get_current_buffer�id)��parameters���Buffer�buffer�can_failëreturn_type�void�name�vim_set_current_buffer�id*��return_type�WindowArray�parameters��name�vim_get_windows�id+��return_type�Window�parameters��name�vim_get_current_window�id,��parameters���Window�window�can_failëreturn_type�void�name�vim_set_current_window�id-��return_type�TabpageArray�parameters��name�vim_get_tabpages�id.��return_type�Tabpage�parameters��name�vim_get_current_tabpage�id/��parameters���Tabpage�tabpage�can_failëreturn_type�void�name�vim_set_current_tabpage�id0��parameters���String�event�id1�return_type�void�receives_channel_idäname�vim_subscribe��parameters���String�event�id2�return_type�void�receives_channel_idäname�vim_unsubscribe��parameters���String�method�can_failëreturn_type�void�receives_channel_idäname�vim_register_provider�id3��parameters���Window�window�can_failëreturn_type�Buffer�name�window_get_buffer�id4��parameters���Window�window�can_failëreturn_type�Position�name�window_get_cursor�id5��parameters���Window�window��Position�pos�can_failëreturn_type�void�name�window_set_cursor�id6��parameters���Window�window�can_failëreturn_type�Integer�name�window_get_height�id7��parameters���Window�window��Integer�height�can_failëreturn_type�void�name�window_set_height�id8��parameters���Window�window�can_failëreturn_type�Integer�name�window_get_width�id9��parameters���Window�window��Integer�width�can_failëreturn_type�void�name�window_set_width�id:��parameters���Window�window��String�name�can_failëreturn_type�Object�name�window_get_var�id;��parameters���Window�window��String�name��Object�value�can_failëreturn_type�Object�name�window_set_var�id<��parameters���Window�window��String�name�can_failëreturn_type�Object�name�window_get_option�id=��parameters���Window�window��String�name��Object�value�can_failëreturn_type�void�name�window_set_option�id>��parameters���Window�window�can_failëreturn_type�Position�name�window_get_position�id?��parameters���Window�window�can_failëreturn_type�Tabpage�name�window_get_tabpage�id@��return_type�Boolean�parameters���Window�window�name�window_is_valid�idA' ] ]

The reply [3][1] should be a map/object.

Their example python-client works by simply unpacking the response.

Decoding the metadata blob works fine with the command-line util this module builds.

$ nvim --api-msgpack-metadata | ./msgpack2json
{"classes":["Buffer","Window","Tabpage"],"functions":[{"parameters":[["Buffer","buffer"]],"can_fail":true,"return_type":"Integer","name":"buffer_get_length","id":1},{"parameters":[["Buffer","buffer"],["Integer","index"]],"can_fail":true,"return_type":"String","name":"buffer_get_line","id":2},{"parameters":[["Buffer","buffer"],["Integer","index"],["String","line"]],"can_fail":true,"return_type":"void","name":"buffer_set_line","id":3},{"parameters":[["Buffer","buffer"],["Integer","index"]],"can_fail":true,"return_type":"void","name":"buffer_del_line","id":4},{"parameters":[["Buffer","buffer"],["Integer","start"],["Integer","end"],["Boolean","include_start"],["Boolean","include_end"]],"can_fail":true,"return_type":"StringArray","name":"buffer_get_slice","id":5},{"parameters":[["Buffer","buffer"],["Integer","start"],["Integer","end"],["Boolean","include_start"],["Boolean","include_end"],["StringArray","replacement"]],"can_fail":true,"return_type":"void","name":"buffer_set_slice","id":6},{"parameters":[["Buffer","buffer"],["String","name"]],"can_fail":true,"return_type":"Object","name":"buffer_get_var","id":7},{"parameters":[["Buffer","buffer"],["String","name"],["Object","value"]],"can_fail":true,"return_type":"Object","name":"buffer_set_var","id":8},{"parameters":[["Buffer","buffer"],["String","name"]],"can_fail":true,"return_type":"Object","name":"buffer_get_option","id":9},{"parameters":[["Buffer","buffer"],["String","name"],["Object","value"]],"can_fail":true,"return_type":"void","name":"buffer_set_option","id":10},{"parameters":[["Buffer","buffer"]],"can_fail":true,"return_type":"Integer","name":"buffer_get_number","id":11},{"parameters":[["Buffer","buffer"]],"can_fail":true,"return_type":"String","name":"buffer_get_name","id":12},{"parameters":[["Buffer","buffer"],["String","name"]],"can_fail":true,"return_type":"void","name":"buffer_set_name","id":13},{"return_type":"Boolean","parameters":[["Buffer","buffer"]],"name":"buffer_is_valid","id":14},{"parameters":[["Buffer","buffer"],["Integer","lnum"],["StringArray","lines"]],"can_fail":true,"return_type":"void","name":"buffer_insert","id":15},{"parameters":[["Buffer","buffer"],["String","name"]],"can_fail":true,"return_type":"Position","name":"buffer_get_mark","id":16},{"parameters":[["Tabpage","tabpage"]],"can_fail":true,"return_type":"WindowArray","name":"tabpage_get_windows","id":17},{"parameters":[["Tabpage","tabpage"],["String","name"]],"can_fail":true,"return_type":"Object","name":"tabpage_get_var","id":18},{"parameters":[["Tabpage","tabpage"],["String","name"],["Object","value"]],"can_fail":true,"return_type":"Object","name":"tabpage_set_var","id":19},{"parameters":[["Tabpage","tabpage"]],"can_fail":true,"return_type":"Window","name":"tabpage_get_window","id":20},{"return_type":"Boolean","parameters":[["Tabpage","tabpage"]],"name":"tabpage_is_valid","id":21},{"return_type":"void","parameters":[["String","str"]],"name":"vim_push_keys","id":22},{"parameters":[["String","str"]],"can_fail":true,"return_type":"void","name":"vim_command","id":23},{"return_type":"void","parameters":[["String","keys"],["String","mode"]],"name":"vim_feedkeys","id":24},{"return_type":"String","parameters":[["String","str"],["Boolean","from_part"],["Boolean","do_lt"],["Boolean","special"]],"name":"vim_replace_termcodes","id":25},{"parameters":[["String","str"]],"can_fail":true,"return_type":"Object","name":"vim_eval","id":26},{"parameters":[["String","str"]],"can_fail":true,"return_type":"Integer","name":"vim_strwidth","id":27},{"return_type":"StringArray","parameters":[],"name":"vim_list_runtime_paths","id":28},{"parameters":[["String","dir"]],"can_fail":true,"return_type":"void","name":"vim_change_directory","id":29},{"parameters":[],"can_fail":true,"return_type":"String","name":"vim_get_current_line","id":30},{"parameters":[["String","line"]],"can_fail":true,"return_type":"void","name":"vim_set_current_line","id":31},{"parameters":[],"can_fail":true,"return_type":"void","name":"vim_del_current_line","id":32},{"parameters":[["String","name"]],"can_fail":true,"return_type":"Object","name":"vim_get_var","id":33},{"parameters":[["String","name"],["Object","value"]],"can_fail":true,"return_type":"Object","name":"vim_set_var","id":34},{"parameters":[["String","name"]],"can_fail":true,"return_type":"Object","name":"vim_get_vvar","id":35},{"parameters":[["String","name"]],"can_fail":true,"return_type":"Object","name":"vim_get_option","id":36},{"parameters":[["String","name"],["Object","value"]],"can_fail":true,"return_type":"void","name":"vim_set_option","id":37},{"return_type":"void","parameters":[["String","str"]],"name":"vim_out_write","id":38},{"return_type":"void","parameters":[["String","str"]],"name":"vim_err_write","id":39},{"return_type":"BufferArray","parameters":[],"name":"vim_get_buffers","id":40},{"return_type":"Buffer","parameters":[],"name":"vim_get_current_buffer","id":41},{"parameters":[["Buffer","buffer"]],"can_fail":true,"return_type":"void","name":"vim_set_current_buffer","id":42},{"return_type":"WindowArray","parameters":[],"name":"vim_get_windows","id":43},{"return_type":"Window","parameters":[],"name":"vim_get_current_window","id":44},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"void","name":"vim_set_current_window","id":45},{"return_type":"TabpageArray","parameters":[],"name":"vim_get_tabpages","id":46},{"return_type":"Tabpage","parameters":[],"name":"vim_get_current_tabpage","id":47},{"parameters":[["Tabpage","tabpage"]],"can_fail":true,"return_type":"void","name":"vim_set_current_tabpage","id":48},{"parameters":[["String","event"]],"id":49,"return_type":"void","receives_channel_id":true,"name":"vim_subscribe"},{"parameters":[["String","event"]],"id":50,"return_type":"void","receives_channel_id":true,"name":"vim_unsubscribe"},{"parameters":[["String","method"]],"can_fail":true,"return_type":"void","receives_channel_id":true,"name":"vim_register_provider","id":51},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Buffer","name":"window_get_buffer","id":52},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Position","name":"window_get_cursor","id":53},{"parameters":[["Window","window"],["Position","pos"]],"can_fail":true,"return_type":"void","name":"window_set_cursor","id":54},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Integer","name":"window_get_height","id":55},{"parameters":[["Window","window"],["Integer","height"]],"can_fail":true,"return_type":"void","name":"window_set_height","id":56},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Integer","name":"window_get_width","id":57},{"parameters":[["Window","window"],["Integer","width"]],"can_fail":true,"return_type":"void","name":"window_set_width","id":58},{"parameters":[["Window","window"],["String","name"]],"can_fail":true,"return_type":"Object","name":"window_get_var","id":59},{"parameters":[["Window","window"],["String","name"],["Object","value"]],"can_fail":true,"return_type":"Object","name":"window_set_var","id":60},{"parameters":[["Window","window"],["String","name"]],"can_fail":true,"return_type":"Object","name":"window_get_option","id":61},{"parameters":[["Window","window"],["String","name"],["Object","value"]],"can_fail":true,"return_type":"void","name":"window_set_option","id":62},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Position","name":"window_get_position","id":63},{"parameters":[["Window","window"]],"can_fail":true,"return_type":"Tabpage","name":"window_get_tabpage","id":64},{"return_type":"Boolean","parameters":[["Window","window"]],"name":"window_is_valid","id":65}]}

Cant build with iojs-v3.0.0

➜  node-msgpack git:(master) ✗ nvm use iojs
Now using system version of node: v3.0.0 (npm v2.13.3)
➜  node-msgpack git:(master) ✗ node-gyp rebuild
....

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
  NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:319:17: note: previous definition is here
  v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                ^
../node_modules/nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                          ^
../node_modules/nan/nan.h:334:27: note: previous definition is here
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:757:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../node_modules/nan/nan.h:768:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/src/node_buffer.h:35:40: note: candidate function not viable: no known conversion from 'uint32_t' (aka 'unsigned int') to 'enum encoding' for 3rd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/hugues/.node-gyp/3.0.0/src/node_buffer.h:47:40: note: candidate function not viable: 2nd argument ('const char *') would lose const qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/hugues/.node-gyp/3.0.0/src/node_buffer.h:32:40: note: candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/hugues/.node-gyp/3.0.0/src/node_buffer.h:40:40: note: candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:772:12: error: no viable conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:210:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to
      'const v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:210:7: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object> &&'
      for 1st argument
class Local {
      ^
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:214:13: note: candidate template ignored: could not match 'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:327:13: note: candidate template ignored: could not match 'S *' against 'v8::MaybeLocal<v8::Object>'
  V8_INLINE Local(S* that)
            ^
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:779:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
../src/msgpack.cc:155:50: warning: 'DecodeBytes' is deprecated: Use DecodeBytes(isolate, ...) [-Wdeprecated-declarations]
        mo->via.raw.size = static_cast<uint32_t>(DecodeBytes(v8obj, UTF8));
                                                 ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:318:32: note: 'DecodeBytes' has been explicitly marked deprecated here
                inline ssize_t DecodeBytes(
                               ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:66:42: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:158:9: warning: 'DecodeWrite' is deprecated: Use DecodeWrite(isolate, ...) [-Wdeprecated-declarations]
        DecodeWrite((char*) mo->via.raw.ptr, mo->via.raw.size, v8obj, UTF8);
        ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:331:32: note: 'DecodeWrite' has been explicitly marked deprecated here
                inline ssize_t DecodeWrite(char* buf,
                               ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:66:42: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:165:50: warning: 'DecodeBytes' is deprecated: Use DecodeBytes(isolate, ...) [-Wdeprecated-declarations]
        mo->via.raw.size = static_cast<uint32_t>(DecodeBytes(result, UTF8));
                                                 ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:318:32: note: 'DecodeBytes' has been explicitly marked deprecated here
                inline ssize_t DecodeBytes(
                               ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:66:42: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:168:9: warning: 'DecodeWrite' is deprecated: Use DecodeWrite(isolate, ...) [-Wdeprecated-declarations]
        DecodeWrite((char*) mo->via.raw.ptr, mo->via.raw.size, result, UTF8);
        ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:331:32: note: 'DecodeWrite' has been explicitly marked deprecated here
                inline ssize_t DecodeWrite(char* buf,
                               ^
/Users/hugues/.node-gyp/3.0.0/src/node.h:66:42: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:316:32: error: no matching function for call to 'NanNewBufferHandle'
    Local<Object> slowBuffer = NanNewBufferHandle(
                               ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:754:36: note: candidate function not viable: no known conversion from 'void (char *, void *)' to 'int' for 3rd argument
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (
                                   ^
../node_modules/nan/nan.h:764:36: note: candidate function not viable: requires 2 arguments, but 4 were provided
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (
                                   ^
../node_modules/nan/nan.h:771:36: note: candidate function not viable: requires single argument 'size', but 4 arguments were provided
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (uint32_t size) {
                                   ^
In file included from ../src/msgpack.cc:1:
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:221:5: error: assigning to 'v8::Primitive *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:501:12: note: in instantiation of function template specialization 'v8::Local<v8::Primitive>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:221:5: error: assigning to 'v8::Boolean *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:511:12: note: in instantiation of function template specialization 'v8::Local<v8::Boolean>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:221:5: error: assigning to 'v8::Function *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1645:12: note: in instantiation of function template specialization 'v8::Local<v8::Function>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:221:5: error: assigning to 'v8::Object *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/hugues/.node-gyp/3.0.0/deps/v8/include/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1776:12: note: in instantiation of function template specialization 'v8::Local<v8::Object>::Local<v8::Value>' requested here
    return NanEscapeScope(
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
4 warnings and 11 errors generated.

node >0.4

Hi!

Can't build msgpack under newer node -- Buffer has been changed to not have length
Wonder if you could upgrade the repo?

TIA,
--Vladimir

loss of data

//outputs 1253986239, should output 177347645375
console.log(Msgpack.unpack(Msgpack.pack(177347645375)));

OOM

$ node bench.js 
FATAL ERROR: CALL_AND_RETRY_2 Allocation failed - process out of memory

top shows:

PhysMem: 774M wired, 1738M active, 414M inactive, 2926M used, 1171M free.

Assuming anything it was using is back after it crashes, is this really using a gig of RAM? Ouch.

4GB MBP here.

make fail & npm install msgpack fail too ,can U help me?

when I make the source:
Waf: Entering directory /home/tigerdog-xp/node-msgpack/build' [1/2] cxx: msgpack.cc -> ../build/default/msgpack_1.o ../src/msgpack.cc:6: fatal error: msgpack.h: 没有那个文件或目录(the file or directory does not exist) compilation terminated. Waf: Leaving directory/home/tigerdog-xp/node-msgpack/build'
Build failed: -> task failed (err #1):
{task: cxx msgpack.cc -> msgpack_1.o}
make: *** [msgpack] 错误 1

when I install it through npm :

Waf: Entering directory /home/tigerdog-xp/node-msgpack/build' [1/2] cxx: msgpack.cc -> ../build/default/msgpack_1.o ../src/msgpack.cc:6: fatal error: msgpack.h: 没有那个文件或目录 compilation terminated. Waf: Leaving directory/home/tigerdog-xp/node-msgpack/build'
Build failed: -> task failed (err #1):
{task: cxx msgpack.cc -> msgpack_1.o}
make: *** [msgpack] 错误 1

json2msgpack utility doesn't work

After installing on OSX and running echo '[1, 2, 3]' | json2msgpack I get:

net.js:51
  throw new TypeError('Unsupported fd type: ' + type);
        ^
TypeError: Unsupported fd type: TTY
    at createHandle (net.js:51:9)
    at new Socket (net.js:156:20)
    at Socket.<anonymous> (/usr/local/lib/node_modules/msgpack/bin/json2msgpack:14:9)
    at Socket.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:442:13)

Build on OS X Mountain Lion fails with recent .pkg builds of node

Installing msgpack2 fails if you install node 0.8.8 (and recent versions) from a Mac OS X .pkg installer, rather than using the n tool to install and compile node from source.

Here is the last few lines of output from 'npm install msgpack2' with both node install scenarios.

With the .pkg installer:

Waf: Entering directory `/Users/mara/Documents/tmp/node_modules/msgpack2/build'
[1/2] cxx: msgpack.cc -> ../build/Release/msgpack_1.o
[2/2] cxx_link: ../build/Release/msgpack_1.o -> ../build/Release/mpBindings.node
ld: warning: ignoring file ../deps/msgpack-full/cpp/dist/lib/libmsgpack.a, file was built for archive which is not the architecture being linked (i386): ../deps/msgpack-full/cpp/dist/lib/libmsgpack.a
Waf: Leaving directory `/Users/mara/Documents/tmp/node_modules/msgpack2/build'
'build' finished successfully (1.207s)
[email protected] node_modules/msgpack2

With node compiled and installed by the 'n' tool:

Waf: Entering directory `/Users/peter/webstorm_workspace/draw-with-friends/mspacktest/node_modules/msgpack2/build'
[1/2] cxx: msgpack.cc -> ../build/Release/msgpack_1.o
[2/2] cxx_link: ../build/Release/msgpack_1.o -> ../build/Release/mpBindings.node
Waf: Leaving directory `/Users/peter/webstorm_workspace/draw-with-friends/mspacktest/node_modules/msgpack2/build'
'build' finished successfully (0.838s)
[email protected] node_modules/msgpack2

So I guess, if you want to install msgpack2, install node using 'n' or maybe node installed from source somehow. We ran diffs over the configure and make output flying past and couldn't spot any differences other than how we'd installed node.

node-msgpack doesn't work on 0.11.11 version

Hello everyone!

I'm using 0.11.11 version of node.js and I'm trying execute other module which uses this library and it's just impossible. This is the error:

  dani@dani-portatil:~/proyectos_eclipse/tfg-pentesting$ node ejemplo.js 

  module.js:349
    Module._extensions[extension](this, filename);
                           ^
  Error: Module did not self-register.
      at Module.load (module.js:349:32)
      at Function.Module._load (module.js:305:12)
      at Module.require (module.js:357:17)
      at require (module.js:373:17)
      at Object.<anonymous> (/home/dani/proyectos_eclipse/tfg-pentesting/node_modules/msfnode/node_modules/msgpack/lib/msgpack.js:6:14)
      at Module._compile (module.js:449:26)
      at Object.Module._extensions..js (module.js:467:10)
      at Module.load (module.js:349:32)
      at Function.Module._load (module.js:305:12)
      at Module.require (module.js:357:17)

Can you help me?

Thanks!

Could not install

python 2

➜ npm install --python=python2

> [email protected] install node_modules/msgpack
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Command failed: python2 -c import platform; print(platform.python_version());
gyp ERR! stack python2: posix_spawn: /usr/bin/python22.7: No such file or directory
gyp ERR! stack 
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:751:12)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at maybeClose (child_process.js:1015:16)
gyp ERR! stack     at Socket.<anonymous> (child_process.js:1183:11)
gyp ERR! stack     at Socket.emit (events.js:107:17)
gyp ERR! stack     at Pipe.close (net.js:485:12)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/msgpack
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--python=python2"
npm ERR! node v0.12.7
npm ERR! npm  v3.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     npm-debug.log

python 2.5

➜ npm install --python=python2.5

> [email protected] install node_modules/msgpack
> node-gyp rebuild

/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py:883: Warning: 'as' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 11, in <module>
    import gyp
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 8, in <module>
    import gyp.input
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 883
    except ImportError as e:
                        ^
SyntaxError: invalid syntax
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:355:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd node_modules/msgpack
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--python=python2.5"
npm ERR! node v0.12.7
npm ERR! npm  v3.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!    npm-debug.log

python 2.6

➜ npm install --python=python2.6

> [email protected] install node_modules/msgpack
> node-gyp rebuild

  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 612, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 28, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 43, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 246, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: can't use a string pattern on a bytes-like object
make: *** [Release/msgpack.a] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd node_modules/msgpack
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--python=python2.6"
npm ERR! node v0.12.7
npm ERR! npm  v3.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     npm-debug.log

python 2.7

➜ npm install --python=python2.7

> [email protected] install node_modules/msgpack
> node-gyp rebuild

  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
Traceback (most recent call last):
  File "./gyp-mac-tool", line 612, in <module>
    sys.exit(main(sys.argv[1:]))
  File "./gyp-mac-tool", line 28, in main
    exit_code = executor.Dispatch(args)
  File "./gyp-mac-tool", line 43, in Dispatch
    return getattr(self, method)(*args[1:])
  File "./gyp-mac-tool", line 246, in ExecFilterLibtool
    if not libtool_re.match(line) and not libtool_re5.match(line):
TypeError: can't use a string pattern on a bytes-like object
make: *** [Release/msgpack.a] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd node_modules/msgpack
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Darwin 14.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--python=python2.7"
npm ERR! node v0.12.7
npm ERR! npm  v3.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     npm-debug.log
  • I tried npm 2 and 3

I give up 🚶

Erroneous cycle detection

This is not a circular reference, its merely a multiple reference

> var mp = require('msgpack');
undefined
> d = new Date
Tue Oct 23 2012 16:30:04 GMT-0700 (PDT)
> mp.pack({a:d, b:d});
TypeError: Cowardly refusing to pack object with circular reference
    at repl:1:4
    at REPLServer.self.eval (repl.js:111:21)
    at rli.on.e (repl.js:260:20)
    at REPLServer.self.eval (repl.js:118:5)
    at Interface.<anonymous> (repl.js:250:12)
    at Interface.EventEmitter.emit (events.js:88:17)
    at Interface._onLine (readline.js:199:10)
    at Interface._line (readline.js:517:8)
    at Interface._ttyWrite (readline.js:735:14)
    at ReadStream.onkeypress (readline.js:98:10)

Proposal Update v5

There's been a debate over how to properly handle string serialization in languages with both string and binary support (the case with node.js) and this resulted in the msgpack owners redefining the spec and adding string support.

Please see the proposal update v5 documentation here: https://gist.github.com/frsyuki/5432559

Have you taken a look? What are the plans etc. Anything I can help with?

Can't install msgpack :(((((((

I got this error when I try to do npm install msgpack

I have try with all the versions of nodejs...

mbp-de-camille-2:server Camille$ npm install msgpack clean
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data

> [email protected] install /Users/Camille/Desktop/agar-mini-map/server/node_modules/msgpack
> node-gyp rebuild

  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
../deps/msgpack/unpack.c:59:43: warning: missing field 'via' initializer
      [-Wmissing-field-initializers]
{ msgpack_object o = { MSGPACK_OBJECT_NIL }; return o; }
                                          ^
1 warning generated.
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
  CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:324:27: error: redefinition of
      'NanEnsureHandleOrPersistent'
  NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:319:17: note: previous definition is here
  v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                ^
../node_modules/nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                          ^
../node_modules/nan/nan.h:334:27: note: previous definition is here
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:757:13: error: no member named 'smalloc' in namespace
      'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../node_modules/nan/nan.h:768:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/node_buffer.h:31:40: note: 
      candidate function not viable: no known conversion from 'uint32_t'
      (aka 'unsigned int') to 'enum encoding' for 3rd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/Camille/.node-gyp/4.2.4/include/node/node_buffer.h:43:40: note: 
      candidate function not viable: 2nd argument ('const char *') would lose
      const qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/Camille/.node-gyp/4.2.4/include/node/node_buffer.h:28:40: note: 
      candidate function not viable: requires 2 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/Camille/.node-gyp/4.2.4/include/node/node_buffer.h:36:40: note: 
      candidate function not viable: requires 5 arguments, but 3 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:772:12: error: no viable conversion from
      'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:210:7: note: candidate
      constructor (the implicit copy constructor) not viable: no known
      conversion from 'v8::MaybeLocal<v8::Object>' to 'const
      v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:210:7: note: candidate
      constructor (the implicit move constructor) not viable: no known
      conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object> &&'
      for 1st argument
class Local {
      ^
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:214:13: note: candidate
      template ignored: could not match 'Local' against 'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:326:13: note: candidate
      template ignored: could not match 'S *' against
      'v8::MaybeLocal<v8::Object>'
  V8_INLINE Local(S* that)
            ^
In file included from ../src/msgpack.cc:9:
../node_modules/nan/nan.h:779:26: error: no member named 'Use' in namespace
      'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
../src/msgpack.cc:155:50: warning: 'DecodeBytes' is deprecated: Use
      DecodeBytes(isolate, ...) [-Wdeprecated-declarations]
        mo->via.raw.size = static_cast<uint32_t>(DecodeBytes(v8obj, UTF8));
                                                 ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:318:32: note: 'DecodeBytes'
      has been explicitly marked deprecated here
                inline ssize_t DecodeBytes(
                               ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:66:42: note: expanded from
      macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:158:9: warning: 'DecodeWrite' is deprecated: Use
      DecodeWrite(isolate, ...) [-Wdeprecated-declarations]
        DecodeWrite((char*) mo->via.raw.ptr, mo->via.raw.size, v8obj, UTF8);
        ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:331:32: note: 'DecodeWrite'
      has been explicitly marked deprecated here
                inline ssize_t DecodeWrite(char* buf,
                               ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:66:42: note: expanded from
      macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:165:50: warning: 'DecodeBytes' is deprecated: Use
      DecodeBytes(isolate, ...) [-Wdeprecated-declarations]
        mo->via.raw.size = static_cast<uint32_t>(DecodeBytes(result, UTF8));
                                                 ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:318:32: note: 'DecodeBytes'
      has been explicitly marked deprecated here
                inline ssize_t DecodeBytes(
                               ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:66:42: note: expanded from
      macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:168:9: warning: 'DecodeWrite' is deprecated: Use
      DecodeWrite(isolate, ...) [-Wdeprecated-declarations]
        DecodeWrite((char*) mo->via.raw.ptr, mo->via.raw.size, result, UTF8);
        ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:331:32: note: 'DecodeWrite'
      has been explicitly marked deprecated here
                inline ssize_t DecodeWrite(char* buf,
                               ^
/Users/Camille/.node-gyp/4.2.4/include/node/node.h:66:42: note: expanded from
      macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                                         ^
../src/msgpack.cc:316:32: error: no matching function for call to
      'NanNewBufferHandle'
    Local<Object> slowBuffer = NanNewBufferHandle(
                               ^~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:754:36: note: candidate function not viable: no known
      conversion from 'void (char *, void *)' to 'int' for 3rd argument
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (
                                   ^
../node_modules/nan/nan.h:764:36: note: candidate function not viable: requires
      2 arguments, but 4 were provided
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (
                                   ^
../node_modules/nan/nan.h:771:36: note: candidate function not viable: requires
      single argument 'size', but 4 arguments were provided
  NAN_INLINE v8::Local<v8::Object> NanNewBufferHandle (uint32_t size) {
                                   ^
In file included from ../src/msgpack.cc:1:
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:221:5: error: assigning to
      'v8::Primitive *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:180:37: note: expanded from
      macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:501:12: note: in instantiation of function template
      specialization 'v8::Local<v8::Primitive>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:221:5: error: assigning to
      'v8::Boolean *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:180:37: note: expanded from
      macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:511:12: note: in instantiation of function template
      specialization 'v8::Local<v8::Boolean>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:221:5: error: assigning to
      'v8::Function *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:180:37: note: expanded from
      macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1645:12: note: in instantiation of function template
      specialization 'v8::Local<v8::Function>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/msgpack.cc:1:
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:221:5: error: assigning to
      'v8::Object *volatile' from incompatible type 'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/Camille/.node-gyp/4.2.4/include/node/v8.h:180:37: note: expanded from
      macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1776:12: note: in instantiation of function template
      specialization 'v8::Local<v8::Object>::Local<v8::Value>' requested here
    return NanEscapeScope(
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
4 warnings and 11 errors generated.
make: *** [Release/obj.target/msgpackBinding/src/msgpack.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/Camille/.nvm/versions/node/v4.2.4/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/Users/Camille/.nvm/versions/node/v4.2.4/bin/node" "/Users/Camille/.nvm/versions/node/v4.2.4/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Camille/Desktop/agar-mini-map/server/node_modules/msgpack
gyp ERR! node -v v4.2.4
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok 
npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/Camille/.nvm/versions/node/v4.2.4/bin/node" "/Users/Camille/.nvm/versions/node/v4.2.4/bin/npm" "install" "msgpack" "clean"
npm ERR! node v4.2.4
npm ERR! npm  v2.14.12
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Camille/Desktop/agar-mini-map/server/npm-debug.log

The results in the readme are misleading

I just run the benchmark on node 4.x here and msgpack is way slower than JSON.

↪ ./run_tests test/benchmark/benchmark.js

benchmark.js

msgpack.pack: 7171ms, JSON.stringify: 2373ms
ratio of JSON.stringify/msgpack.pack: 0.33091619021057034
✔ benchmark - JSON.stringify faster than msgpack.pack with array of 1m objects

msgpack.pack: 8614ms, JSON.stringify: 3252ms
ratio of msgpack.pack/JSON.stringify: 2.648831488314883
✔ benchmark - JSON.stringify faster than msgpack.pack over 1m calls

msgpack.unpack: 4959ms, JSON.parse: 1522ms
ratio of JSON.parse/msgpack.unpack: 3.2582128777923787
✔ benchmark - JSON.parse faster than msgpack.unpack over 1m calls

msgpack pack:   6622 ms
msgpack unpack: 9435 ms
json    pack:   2983 ms
json    unpack: 3738 ms

msgpack pack:   13744 ms
msgpack unpack: 28709 ms
json    pack:   3352 ms
json    unpack: 3732 ms

msgpack pack:   11742 ms
msgpack unpack: 24797 ms
json    pack:   3187 ms
json    unpack: 3829 ms

✔ benchmark - output above is from three runs on a 1m element array of objects

msgpack pack:   9234 ms
msgpack unpack: 6004 ms
json    pack:   3019 ms
json    unpack: 1953 ms

msgpack pack:   9205 ms
msgpack unpack: 5706 ms
json    pack:   2491 ms
json    unpack: 1536 ms

msgpack pack:   8342 ms
msgpack unpack: 5194 ms
json    pack:   2471 ms
json    unpack: 1541 ms

✔ benchmark - output above is from three runs of 1m individual calls

OK: 5 assertions (217708ms)

Package could not be built if parent directory of package contains white space

It seems that use PWD in Makefile is not a good idea.

I can reproduce this problem as follow:

$ cd /tmp
$ mkdir a\ b
$ git clone https://github.com/pgriess/node-msgpack.git
Cloning into 'node-msgpack'...
remote: Counting objects: 319, done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 319 (delta 136), reused 272 (delta 128)
Receiving objects: 100% (319/319), 462.26 KiB | 127 KiB/s, done.
Resolving deltas: 100% (136/136), done.
$ cd node-msgpack 
$ make
cd deps/msgpack && \
        mkdir -p dist && \
        ./configure --enable-static --disable-shared \
            --prefix=/tmp/a b/node-msgpack/deps/msgpack/dist && \
        make && \
        make install
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: b/node-msgpack/deps/msgpack/dist
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for b/node-msgpack/deps/msgpack/dist-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for b/node-msgpack/deps/msgpack/dist-g++... no
checking for b/node-msgpack/deps/msgpack/dist-c++... no
checking for b/node-msgpack/deps/msgpack/dist-gpp... no
checking for b/node-msgpack/deps/msgpack/dist-aCC... no
checking for b/node-msgpack/deps/msgpack/dist-CC... no
checking for b/node-msgpack/deps/msgpack/dist-cxx... no
checking for b/node-msgpack/deps/msgpack/dist-cc++... no
checking for b/node-msgpack/deps/msgpack/dist-cl.exe... no
checking for b/node-msgpack/deps/msgpack/dist-FCC... no
checking for b/node-msgpack/deps/msgpack/dist-KCC... no
checking for b/node-msgpack/deps/msgpack/dist-RCC... no
checking for b/node-msgpack/deps/msgpack/dist-xlC_r... no
checking for b/node-msgpack/deps/msgpack/dist-xlC... no
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
configure: WARNING: Libtool does not cope well with whitespace in `pwd`
checking build system type... Invalid configuration `b/node-msgpack/deps/msgpack/dist': machine `b/node' not recognized
configure: error: /bin/bash ac/config.sub b/node-msgpack/deps/msgpack/dist failed
make: *** [deps/msgpack/dist/lib/libmsgpack.a] Error 1

Update readme.md to reflect string/binary handling

Just wanted to say I almost abandoned using this project, as it appeared that it did not support the new msgpack v5 string/binary distinctions. Just updating the references in readme.md to MSGPACK_OBJECT_RAW to instead reflect that binary is properly parsed as Buffer (and string data as string) might prevent some confusion. Other than that, this appears to be the best msgpack library available for Node.js (both perf and stability), so needless to say I'm glad I decided to try out the binary/string handling before abandoning it. Thanks!

feature request: toJSON()

It would be really nice if msgpack could directly turn its binary representation into a JSON string, avoiding parse from msgpack -> stringify to JSON. Besides the potential performance benefit, not having this step would avoid a lot of object creation, which could really help the garbage collector to take it easy.

Fails to store big integers

I've added a new test to test.js

testEqual(123456782345245);

wicked@wicked-desktop:~/Alawar/h-n/node_modules/msgpack-0.4/test$ node test.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
AssertionError: 123456782345245 deepEqual 2242389021
at /home/wicked/Alawar/h-n/node_modules/msgpack-0.4/test/test.js:7:12
at Object. (/home/wicked/Alawar/h-n/node_modules/msgpack-0.4/test/test.js:24:1)
at Module._compile (module.js:407:26)
at Object..js (module.js:413:10)
at Module.load (module.js:339:31)
at Function._load (module.js:298:12)
at Array. (module.js:426:10)
at EventEmitter._tickCallback (node.js:126:26)

I expected it to pass and restore the same integer 123456782345245 from the message.

Support node.js 0.9.x

$ npm rebuild
> [email protected] preinstall /Users/crabdude/Dropbox/redrobot/westeros/server/node_modules/shuttle/node_modules/msgpack3
> node-gyp configure build

  CXX(target) Release/obj.target/binding/binding.o
  CXX(target) Release/obj.target/msgpack3/src/msgpack3.o
../src/msgpack3.cc:1:9: warning: 'BUILDING_NODE_EXTENSION' macro redefined
#define BUILDING_NODE_EXTENSION
        ^
<command line>:4:9: note: previous definition is here
#define BUILDING_NODE_EXTENSION 1
        ^
../src/msgpack3.cc:41:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint16_t read2Bytes(const uint8_t *buf, const uint32_t offset){
       ^~~~~
../src/msgpack3.cc:49:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint32_t read4Bytes(const uint8_t *buf, const uint32_t offset){
       ^~~~~
../src/msgpack3.cc:59:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t sizeof_logic(const uint8_t arg) {
       ^~~~~
../src/msgpack3.cc:72:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t sizeof_number(const uint8_t arg) {
       ^~~~~
../src/msgpack3.cc:99:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t sizeof_raw(const uint8_t arg){
       ^~~~~
../src/msgpack3.cc:116:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t sizeof_array(const uint8_t arg){
       ^~~~~
../src/msgpack3.cc:133:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t sizeof_map(const uint8_t arg){
       ^~~~~
../src/msgpack3.cc:150:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t type(const Local<Value>& arg){
       ^~~~~
../src/msgpack3.cc:221:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint8_t reverseType(const uint8_t obj){
       ^~~~~
../src/msgpack3.cc:237:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint32_t sizeof_obj(const Local<Value>& obj){
       ^~~~~
../src/msgpack3.cc:272:8: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
static const uint32_t pack(const Local<Value>& obj, uint8_t *data){
       ^~~~~
../src/msgpack3.cc:652:23: error: address of overloaded function 'Init' does not match required type 'void
      (v8::Handle<v8::Object>, v8::Handle<v8::Value>)'
NODE_MODULE(msgpack3, Init)
~~~~~~~~~~~~~~~~~~~~~~^~~~~
/Users/crabdude/.node-gyp/0.9.9/src/node.h:240:34: note: expanded from macro 'NODE_MODULE'
      (node::addon_register_func)regfunc,                             \
                                 ^
../src/msgpack3.cc:645:6: note: candidate function has different number of parameters (expected 2 but has 1)
void Init(Handle<Object> target) {
     ^
/Users/crabdude/.node-gyp/0.9.9/src/node.h:93:8: note: candidate function has type mismatch at 1st parameter (expected
      'v8::Handle<v8::Object>' but has 'int')
char** Init(int argc, char *argv[]);
       ^
12 warnings and 1 error generated.
make: *** [Release/obj.target/msgpack3/src/msgpack3.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:255:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:97:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:731:12)
gyp ERR! stack     at process._makeCallback (node.js:321:24)
gyp ERR! System Darwin 11.4.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/crabdude/Dropbox/redrobot/westeros/server/node_modules/shuttle/node_modules/msgpack3
gyp ERR! node -v v0.9.9
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok 

> [email protected] uninstall /Users/crabdude/Dropbox/redrobot/westeros/server/node_modules/shuttle/node_modules/msgpack3
> node-gyp clean

npm ERR! [email protected] preinstall: `node-gyp configure build`
npm ERR! `sh "-c" "node-gyp configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the msgpack3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack3
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 11.4.2
../binding.cc:512:5: error: no matching function for call to 'uv_queue_work'
    uv_queue_work(uv_default_loop(), req, UV_BindAsync, UV_BindAsyncAfter);
    ^~~~~~~~~~~~~
npm ERR! command "/usr/local/n/versions/0.9.9/bin/node" "/usr/local/bin/npm" "install" "shuttle"
npm ERR! cwd /Users/crabdude/Dropbox/redrobot/westeros/server
npm ERR! node -v v0.9.9
npm ERR! npm -v 1.2.10
npm ERR! code ELIFECYCLE
/Users/crabdude/.node-gyp/0.9.9/deps/uv/include/uv.h:1393:15: note: candidate function not viable: no known conversion
      from 'void (uv_work_t *)' to 'uv_after_work_cb' (aka 'void (*)(uv_work_t *, int)') for 4th argument;
UV_EXTERN int uv_queue_work(uv_loop_t* loop, uv_work_t* req,
              ^
error: error opening './Release/.deps/Release/obj.target/binding/binding.o.d.raw': Error opening output file
      './Release/.deps/Release/obj.target/binding/binding.o.d.raw'
2 errors generated.
make: *** [Release/obj.target/binding/binding.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:255:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:97:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:731:12)
gyp ERR! stack     at process._makeCallback (node.js:321:24)
gyp ERR! System Darwin 11.4.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! UNCAUGHT EXCEPTION 
gyp ERR! stack Error: ENOENT, no such file or directory
gyp ERR! stack     at errorMessage (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:119:28)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:76:7
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:255:14)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:97:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:731:12)
gyp ERR! stack     at process._makeCallback (node.js:321:24)
gyp ERR! System Darwin 11.4.2
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"

/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:119
  log.error('cwd', process.cwd())
                           ^
Error: ENOENT, no such file or directory
    at errorMessage (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:119:28)
    at issueMessage (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:125:3)
    at process.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:109:3)
    at process.EventEmitter.emit (events.js:94:17)
    at process._fatalException (node.js:259:26)

msgpack.cc(181): error C2466

Hi at all,

my configuration is:

  • Windows 7 64BIT
  • Node.JS 0.10.10
  • Python 2.7

When i try to lauch "nmp install msgpack" i get this error:

libmsgpack.vcxproj .> c:\program Files\nodejs\node_modules\msgpack\build\Release\libmsgpack.lib
msgpack.cc
..\src\msgpack.cc(181): error C2466

Can anyone help me to resolve?

Daniele

Feature request: be compatible with toJSON functions

toJSON is a standard function, which, if present on an object, get's called to return the contents of the object instead of a JSON serializer attempting to enumerate.
It would be nice if we could re-use our toJSON functions with msgpack without having to write some sort of adapter.
That is, msgpack will check each object it is ready to serialize for a toJSON function, and if one is present, use the data from it to build the serialized version of that object.

Date Handling

msg.unpack(msg.pack(new Date())) is returning a blank object.

That's not exactly unsurprising...

build error on node 0.6.11

'configure' finished successfully (0.213s)
Waf: Entering directory `/home/btcanalytics/node_modules/msgpack/build'
[1/2] cxx: msgpack.cc -> ../build/Release/msgpack_1.o
../src/msgpack.cc: In function 'v8::Handle<v8::Value> pack(const v8::Arguments&)':
../src/msgpack.cc:292:16: error: 'class node::Buffer' has no member named 'data'
../src/msgpack.cc: In function 'v8::Handle<v8::Value> unpack(const v8::Arguments&)':
../src/msgpack.cc:320:33: error: 'class node::Buffer' has no member named 'data'
../src/msgpack.cc:320:46: error: 'class node::Buffer' has no member named 'length'
../src/msgpack.cc:326:35: error: 'class node::Buffer' has no member named 'length'
../src/msgpack.cc:340:1: warning: control reaches end of non-void function [-Wreturn-type]

Not installing on Windows

Hello!
Can this library be used on Windows?
I have latest node version on Windows 7 (node v0.12.3) and latest npm version (npm 2.10.0).
I also have Python installed on the machine and I already registered it:
npm config set python D:\python
... but when I try to install memcached client on my node project I get the following error stacktrace:

npm install msgpack --save
/
> [email protected] install D:\xampp\htdocs\exp0\node_modules\msgpack
> node-gyp rebuild


D:\xampp\htdocs\exp0\node_modules\msgpack>if not defined npm_config_node_gyp (node "C:\Users\User\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuild)
gyp ERR! configure error
gyp ERR! stack Error: spawn D:\python ENOENT
gyp ERR! stack     at exports._errnoException (util.js:746:11)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
gyp ERR! stack     at child_process.js:1144:20
gyp ERR! stack     at process._tickCallback (node.js:355:11)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\xampp\htdocs\exp0\node_modules\msgpack
gyp ERR! node -v v0.12.3
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "node" "C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "msgpack" "--save"
npm ERR! node v0.12.3
npm ERR! npm  v2.10.0
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the msgpack package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls msgpack
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\xampp\htdocs\exp0\npm-debug.log

Any idea about how to overcome this?
Thanks a lot

Encoding/Decoding messagepack data with Node.js Buffers

I'm using node-msgpack to encode and decode messages passed around between machines. One thing I'd like to be able to do is wrap raw Buffer data in an object and encode that with Messagepack.

msgpack = require('msgpack')
buf = <Buffer ac 48 65 6c 6c 6f 20 57 6f 72 6c 64 21>
obj = {foo: buf}
packed = msgpack.pack(obj)

In the example above, I wanted to do a consistency check on the raw bytes of buffers nested in an object. So buf was obtained like so :

buf = msgpack.pack("Hello World!")

In a perfect world, I would have obtained :

msgpack.unpack(new Buffer(msgpack.unpack(packed).foo));

#> "Hello World!"

Instead, I end up with -17. Digging up a little deeper, I end up with the following curiosity:

enc = 'ascii'
new Buffer(buf.toString(enc), enc)
#> <Buffer fd 48 65 6c 6c 6f 20 57 6f 72 6c 64 21>

buf
#> <Buffer ac 48 65 6c 6c 6f 20 57 6f 72 6c 64 21>

The first byte is the problem. I tried using different encoding with no luck. What is happening here and what can I do to do circumvent the issue?

Make problems in Snow Leopard

Hi,

I get the following error when trying to build msgpack in Snow Leopard:

[jfd@RevF node-msgpack(master)]$ make CC=gcc-4.2 CXX=gcc-4.2
cd src &&
node-waf configure &&
node-waf build
Checking for program g++ or c++ : gcc-4.2
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node prefix : ok /usr/local
'configure' finished successfully (0.039s)
Waf: Entering directory /Users/jfd/checkouts/node-msgpack/build' [1/2] cxx: msgpack.cc -> ../build/default/msgpack_1.o ../src/msgpack.cc: In function ‘v8::Handle<v8::Value> pack(const v8::Arguments&)’: ../src/msgpack.cc:205: error: no matching function for call to ‘node::Buffer::New(size_t&)’ /usr/local/include/node/node_buffer.h:51: note: candidates are: static v8::Handle<v8::Value> node::Buffer::New(const v8::Arguments&) ../src/msgpack.cc: In function ‘v8::Handle<v8::Value> unpack(const v8::Arguments&)’: ../src/msgpack.cc:237: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’ Waf: Leaving directory/Users/jfd/checkouts/node-msgpack/build'
Build failed: -> task failed (err #1):
{task: cxx msgpack.cc -> msgpack_1.o}
make: *** [msgpack] Error 1

msgpack 1.0.2 does not install on Debian 6

Debian 6 only supports g++ up to version 4.4 which I don't think has c++11 support in it. The previous version of msgpack we were using installed and worked great. We only ran into this when we went to upgrade Node.js to v4.0.

make: Entering directory `/root/node_modules/msgpack/build'
CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
AR(target) Release/obj.target/deps/msgpack/msgpack.a
COPY Release/msgpack.a
CXX(target) Release/obj.target/msgpackBinding/src/msgpack.o
cc1plus: error: unrecognized command line option "-std=c++11"
make: *** [Release/obj.target/msgpackBinding/src/msgpack.o] Error 1

installation error on CentOS 6.4 : UNKNOWN, symlink

hi all
im trying to install msgpack on centos using 'npm install msgpack' but get this error:

npm http GET https://registry.npmjs.org/msgpack
npm http 200 https://registry.npmjs.org/msgpack
npm http GET https://registry.npmjs.org/msgpack/-/msgpack-0.2.1.tgz
npm http 200 https://registry.npmjs.org/msgpack/-/msgpack-0.2.1.tgz
npm ERR! Error: UNKNOWN, symlink '../msgpack/bin/msgpack2json'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 2.6.32-358.el6.i686
npm ERR! command "node" "/usr/bin/npm" "install" "msgpack"
npm ERR! cwd /mnt/hgfs/Programming/node/fim
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.2.17
npm ERR! path ../msgpack/bin/msgpack2json
npm ERR! code UNKNOWN
npm ERR! errno -1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /mnt/hgfs/Programming/node/fim/npm-debug.log
npm ERR! not ok code 0

is there anything that i missed?

thanks in advance

Pack of (- 2^31-1) is wrong

In Python:

from struct import *
pack('q', -2147483649)

will yield \xff\xff\xff\x7f\xff\xff\xff\xff

Which is what I'd expected too (the Big Endian two's complement of -2147483649 )

Also, the Python msgpack library gets it right:

import msgpack
msgpack.packb(-2147483649)

Yields: \xd3\xff\xff\xff\xff\x7f\xff\xff\xff

Here's how it works with the Node purepack module (which I maintain and use msgpack to test against):

pp = require 'purepack'
pp.pack(-2147483649, 'buffer')
<Buffer d3 ff ff ff ff 7f ff ff ff>

I had to jump through some hoops to get this working in pure JavaScript, I'm not sure if there's a better way with the V8 extension method...

Make problems in Ubuntu 10.04

This is what happens:

maushu@graphnode:~/src/node-msgpack$ make
cd src && \
              node-waf configure && \
              node-waf build
Checking for program g++ or c++          : /usr/bin/g++
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for g++                         : ok
Checking for node prefix                 : ok /usr/local
'configure' finished successfully (0.031s)
Waf: Entering directory `/home/mau/src/node-msgpack/build'
[1/2] cxx: msgpack.cc -> ../build/default/msgpack_1.o
../src/msgpack.cc: In function âv8::Handle<v8::Value> pack(const v8::Arguments&)â:
../src/msgpack.cc:205: error: no matching function for call to ânode::Buffer::New(size_t&)â
/usr/local/include/node/node_buffer.h:51: note: candidates are: static v8::Handle<v8::Value> node::Buffer::New(const v8::Arguments&)
Waf: Leaving directory `/home/mau/src/node-msgpack/build'
Build failed:  -> task failed (err #1):
        {task: cxx msgpack.cc -> msgpack_1.o}
make: *** [msgpack] Error 1
mau@graphnode:~/src/node-msgpack$

About the performance

I just run the bench.js with msgpack-js, the results is different from README.md.

$ node msgpack.js 
20
msgpack pack:   6073 ms
msgpack unpack: 2098 ms
22
msgpack-js pack:   7004 ms
msgpack-js unpack: 1501 ms
36
json    pack:   1714 ms
json    unpack: 823 ms

JSON is much faster than magpack.

node version is v0.8.16.

Fail to install on mac osx yosemite, libtool: unrecognized option `-static'

> [email protected] install /Users/diwu/Documents/Projects/BetterWorks/appfiles/node_modules/msgpack
> node-gyp rebuild

  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/gcc_atomic.o
  CXX(target) Release/obj.target/libmsgpack/deps/msgpack/object.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/objectc.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/unpack.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/vrefbuffer.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/zone.o
  CC(target) Release/obj.target/libmsgpack/deps/msgpack/version.o
  LIBTOOL-STATIC Release/msgpack.a
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make: *** [Release/msgpack.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2

RAM usage

I am currently testing msgpack vs raw object storage vs protobuf into an ES6 Map (using node 5.x)

There seems to be some kind of memory issue with the current implementation of node-msgpack.

Surprisingly when creating 10.000.000 entries using this function

function createRandomEntry(){
  return { id: uuid.v1(), v:38, p: uuid.v1(), l:[0,2,4,5,9,8,10], seq:12343432 };
}

using (in a loop of course)

var entry = createRandomEntry();
var packedEntry = msgpack.pack(entry);
map.set(entry.id, packedEntry);

the heap ram runs out of control. it wants to consume >30GB and isnt finished building the map yet. maximum ram usage storing the original entries without msgpack is only ~12GB. The original entries are not referenced anymore and i doesnt matter wether i run global.gc during insert (every 10000 entries for example).

Is there any kind of data-structure built up per item packed ?

Again: The exact same code without running pack (storing the original entry) is about 12GB heap. Also running with protobuf instead of msgpack maxes out at less then 3 GB RAM. I would expect protobuf to be better of course (since the schema is known and fixed) but the RAM usage of each single item should be less than the original json.

The original msgpack encoded buffer is 104 bytes
The protobuf encoded buffer is 92 bytes
The rough estimated in memory size of the raw json is 312 bytes

If anything i would have expected the msgpack RAM to be a third ~4 GB instead of ~12GB. The Protobuf memory usage (always including ES6 Map) is 2.1GB.

Date objects are not handled properly

> var msgpack = require('msgpack');
undefined
> var obj = {d: new Date()}
undefined
> msgpack.unpack(msgpack.pack(obj));
{ d: {} }
> var msgpack = require('msgpack');
undefined
> var obj = {d: new Date()}
undefined
> obj
{ d: Fri Oct 26 2012 18:32:26 GMT-0700 (PDT) }
> msgpack.unpack(msgpack.pack(obj));
{ d: {} }

This is a big problem for us. A quick fix is to toString Date objects when packing in msgpack.cc? Other thoughts?

feature request: control over Number packing

If I'm trying to send a message to something that's expecting a MSGPACK_OBJECT_DOUBLE I am currently unable to do so if the number also happens to be an integer - 0 for example - as MSGPACK_OBJECT_POSITIVE_INTEGER is chosen for me and the receiver doesn't know what to do with it.

A possible API could go like this:

var value = new Number(0);
value.msgpackType = msgpack.MSGPACK_OBJECT_DOUBLE; // 4
var msg = msgpack.pack([1, value]);

"Error: Encountered unknown MessagePack object type"

On a 32-bit Linux box, this happens when unpacking a packed array or object.

maushu@graphnode:~/src/node-msgpack$ node test.js
/home/maushu/src/node-msgpack/test.js:6
    var vv = msgpack.unpack(msgpack.pack(v));
                     ^
Error: Encountered unknown MessagePack object type
    at /home/maushu/src/node-msgpack/test.js:6:22
    at Object.<anonymous> (/home/maushu/src/node-msgpack/test.js:45:1)
    at Module._compile (module:384:23)
    at Module._loadScriptSync (module:393:16)
    at Module.loadSync (module:296:10)
    at Object.runMain (module:459:22)
    at node.js:196:8
maushu@graphnode:~/src/node-msgpack$

pack, write, read, unpack => fail

Hi,
a node process exited with the message:
"assertion "handle->InternalFieldCount() > 0" failed: file "/usr/local/include/node/node_object_wrap.h", line 51 ..."
when I try this sequence of steps:

  1. pack an object with msgpack, 2) write a buffer into a file, 3) read a buffer from the file, 4) try to unpack.
    The same error for send/receive over tcp.
    Example of code:
var fs = require('fs'), assert = require('assert'), msgpack = require('msgpack');
var obj = {a:123}, fileName = 'packed-data';
var packedObj = msgpack.pack(obj);
fs.writeFileSync(fileName, packedObj);
packedObj2 = fs.readFileSync(fileName);
assert.deepEqual(packedObj, packedObj2);
var unpackedObj = msgpack.unpack(packedObj2); // crash
assert.deepEqual(obj, unpackedObj);

Node was used on Windows 7 with cygwin.

Can you please suggest something about this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.