darrachequesne / notepack

A fast Node.js implementation of the latest MessagePack spec
MIT License
75 stars 19 forks source link

Notepack mongoose object problem #5

Closed dorukgunes closed 7 years ago

dorukgunes commented 7 years ago

Do you know any elegant way to encode and mongoose object with notepack ? I get a RangeError: Maximum call stack size exceeded when i try to encode and mongoose object.

darrachequesne commented 7 years ago

Did you try toJSON? Or maybe with Query#lean when querying the documents?

dorukgunes commented 7 years ago

That works but in our project it is complicated to change our queries into lean, i am writing this about socket-io redis because in version 5 it uses notepack, before notepack there is no problem with encoding mongoose object. Dou you have any idea how i can change the encoder of socket-io.redis or come over this problem without changing every query.

darrachequesne commented 7 years ago

@dorukgunes and what about toJSON? It seems msgpack-lite does not call toJSON() method when available, but msgpack-js does (there):

if('function' === typeof value.toJSON)
  return encode(value.toJSON(), buffer, offset)
darrachequesne commented 7 years ago

Closed by #8