Skip to content

Commit

Permalink
unpack() returns 'undefined' on incomplete value.
Browse files Browse the repository at this point in the history
- Handle MSGPACK_UNPACK_CONTINUE by returning 'undefined'. Callers
  should be prepared to see this and retry later with more data.
  • Loading branch information
pgriess committed May 27, 2010
1 parent 74002bb commit f22f530
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/msgpack.cc
Expand Up @@ -265,7 +265,8 @@ pack(const Arguments &args) {
// var o = msgpack.unpack(buf);
//
// Return the JavaScript object resulting from unpacking the contents of the
// specified buffer.
// specified buffer. If the buffer does not contain a complete object, the
// undefined value is returned.
static Handle<Value>
unpack(const Arguments &args) {
HandleScope scope;
Expand Down Expand Up @@ -293,6 +294,9 @@ unpack(const Arguments &args) {
} catch (MsgpackException e) {
return e.getThrownException();
}

case MSGPACK_UNPACK_CONTINUE:
return scope.Close(Undefined());

default:
return ThrowException(Exception::Error(
Expand Down

0 comments on commit f22f530

Please sign in to comment.