Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nil evaluation error #67

Open
i-kovalyov opened this issue Apr 2, 2018 · 2 comments
Open

nil evaluation error #67

i-kovalyov opened this issue Apr 2, 2018 · 2 comments

Comments

@i-kovalyov
Copy link
Contributor

I founded that after decoding of 0xc0 byte (nil) from msgpack stream msgpack5 decides that stream is finished and then produces error.

I tried to replace text below from function tryDecode of decoder.js
case 0xc0:
return buildDecodeResult(null, 1)
with
case 0xc0:
return buildDecodeResult(undefined, 1)

This correction fixed error.

However mapping msgpack nil to "undefined" don't looks as best solution.

I tried to fix error another way so, that 0xc0 (nil) maps to null but it's not easy.
Null evaluation as end of stream is hardcoded in readable-stream.
function readableAddChunk of _stream_readable.js has following code:
...
if (chunk === null) {
state.reading = false;
onEofChunk(stream, state);
}
...

Any ideas how to fix this error?

@mcollina
Copy link
Owner

mcollina commented Apr 3, 2018

I think we should either allow to map nil to our own msgpack.Nil object, or output the result of tryDecode in tne decoder (via an option).

@i-kovalyov
Copy link
Contributor Author

Added pull request fixing this error
#68

Msgpack nil is still mapped to null but during stream processing null temprarily replaced to undefined then replaced back to null.

Is this solution appropriate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants