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

Workaround for Node 6.4.0 buffer bug #59

Closed
wants to merge 1 commit into from
Closed

Workaround for Node 6.4.0 buffer bug #59

wants to merge 1 commit into from

Conversation

efarrar
Copy link

@efarrar efarrar commented Sep 28, 2016

Node 6.4.0 introduced a bug ( nodejs/node#8127 ) that causes a Range Error exceptions when writing a zero-length string to a buffer. The bug was fixed in Node 6.5.0, but the current node-hdb throws Range Error exceptions in Node 6.4.0 when attempting to use streams to read a result set.

This change introduces a workaround that checks for zero-length strings, and avoids the write that will fail in Node 6.4.0

Node 6.4.0 introduced a bug ( nodejs/node#8127 ) that causes a Range Error exceptions when writing a zero-length string to a buffer. The bug was fixed in Node 6.5.0, but the current node-hdb throws Range Error exceptions in Node 6.4.0 when attempting to use streams to read a result set.

This change introduces a workaround that checks for zero-length strings, and avoids the write that will fail in Node 6.4.0
@@ -437,7 +437,11 @@ Writer.prototype.writeCharacters = function writeCharacters(value, encoding) {
var type = encoding === 'ascii' ? TypeCode.STRING : TypeCode.NSTRING;
var length = Buffer.byteLength(value, encoding);
var buffer;
if (length <= 245) {
if (length === 0 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't make workarounds in the driver in order to support buggy versions of NodeJS.

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

Successfully merging this pull request may close these issues.

2 participants