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

BufferShortageError on Mac #36

Closed
fed135 opened this issue Apr 28, 2016 · 2 comments
Closed

BufferShortageError on Mac #36

fed135 opened this issue Apr 28, 2016 · 2 comments

Comments

@fed135
Copy link

fed135 commented Apr 28, 2016

I've tried multiple versions of Node on Mac and I keep getting BufferShortageError.
This occurs during benchmarking with buffers of around 5kb. This doesn't happen on Linux.

You can get the code here: https://github.com/fed135/Kalm/tree/master/tests/benchmarks
(You can change the duration of the tests in /tests/settings.js)

node tests/benchmarks

/Users/frederic/node/Kalm/node_modules/msgpack-lite/lib/read-format.js:74
if (end > buffer.length) throw new BufferShortageError();
@kawanet
Copy link
Owner

kawanet commented Jun 11, 2016

@fed135

The error happens when the app does not give enough length of Buffer to msgpack.decode().
A valid msgpack message may be divided into multiple chunks when sending through a network stream.

        /**
         * Handler for receiving data through the listener
         * @private
         * @method handleRequest
         * @memberof Client
         * @param {Buffer} evt The data received
         */
        handleRequest(evt) {
                var raw = encoders.resolve(this.options.encoder).decode(evt);
                if (raw && raw.length) {
                        if (this.channels.hasOwnProperty(raw[0])) {
                                this.channels[raw[0]].handleData(raw[1]);
                        }
                }
        }

I have not dived into the code of Kalm, however, I guess the OS X may divide the receiving data for 8192 bytes chunk each.

Use the Stream model or the Event model of the msgpack-lite module.
Those could manage the multiple chunks divided.

@fed135
Copy link
Author

fed135 commented Jun 11, 2016

Thanks, I will try that

@fed135 fed135 closed this as completed Jun 27, 2016
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