Giter VIP home page Giter VIP logo

node-redis-parser's Introduction

Build Status Coverage Status js-standard-style

redis-parser

A high performance javascript redis parser built for node_redis and ioredis. Parses all RESP data.

Install

Install with NPM:

npm install redis-parser

Usage

const Parser = require('redis-parser');

const myParser = new Parser(options);

Options

  • returnReply: function; mandatory
  • returnError: function; mandatory
  • returnFatalError: function; optional, defaults to the returnError function
  • returnBuffers: boolean; optional, defaults to false
  • stringNumbers: boolean; optional, defaults to false

Functions

  • reset(): reset the parser to it's initial state
  • setReturnBuffers(boolean): set the returnBuffers option on/off without resetting the parser
  • setStringNumbers(boolean): set the stringNumbers option on/off without resetting the parser

Error classes

  • RedisError sub class of Error
  • ReplyError sub class of RedisError
  • ParserError sub class of RedisError

All Redis errors will be returned as ReplyErrors while a parser error is returned as ParserError.
All error classes can be imported by the npm redis-errors package.

Example

const Parser = require("redis-parser");

class Library {
  returnReply(reply) { /* ... */ }
  returnError(err) { /* ... */ }
  returnFatalError(err) { /* ... */ }

  streamHandler() {
    this.stream.on('data', (buffer) => {
      // Here the data (e.g. `Buffer.from('$5\r\nHello\r\n'`))
      // is passed to the parser and the result is passed to
      // either function depending on the provided data.
      parser.execute(buffer);
    });
  }
}

const lib = new Library();

const parser = new Parser({
  returnReply(reply) {
    lib.returnReply(reply);
  },
  returnError(err) {
    lib.returnError(err);
  },
  returnFatalError(err) {
    lib.returnFatalError(err);
  }
});

You do not have to use the returnFatalError function. Fatal errors will be returned in the normal error function in that case.

And if you want to return buffers instead of strings, you can do this by adding the returnBuffers option.

If you handle with big numbers that are to large for JS (Number.MAX_SAFE_INTEGER === 2^53 - 16) please use the stringNumbers option. That way all numbers are going to be returned as String and you can handle them safely.

// Same functions as in the first example

const parser = new Parser({
  returnReply(reply) {
    lib.returnReply(reply);
  },
  returnError(err) {
    lib.returnError(err);
  },
  returnBuffers: true, // All strings are returned as Buffer e.g. <Buffer 48 65 6c 6c 6f>
  stringNumbers: true // All numbers are returned as String
});

// The streamHandler as above

Protocol errors

To handle protocol errors (this is very unlikely to happen) gracefully you should add the returnFatalError option, reject any still running command (they might have been processed properly but the reply is just wrong), destroy the socket and reconnect. Note that while doing this no new command may be added, so all new commands have to be buffered in the meantime, otherwise a chunk might still contain partial data of a following command that was already processed properly but answered in the same chunk as the command that resulted in the protocol error.

Contribute

The parser is highly optimized but there may still be further optimizations possible.

npm install
npm test
npm run benchmark

Currently the benchmark compares the performance against the hiredis parser:

HIREDIS:   $ multiple chunks in a bulk string x 1,169,386 ops/sec ±1.24% (92 runs sampled)
JS PARSER: $ multiple chunks in a bulk string x 1,354,290 ops/sec ±1.69% (88 runs sampled)
HIREDIS BUF:   $ multiple chunks in a bulk string x 633,639 ops/sec ±2.64% (84 runs sampled)
JS PARSER BUF: $ multiple chunks in a bulk string x 1,783,922 ops/sec ±0.47% (94 runs sampled)

HIREDIS:   + multiple chunks in a string x 2,394,900 ops/sec ±0.31% (93 runs sampled)
JS PARSER: + multiple chunks in a string x 2,264,354 ops/sec ±0.29% (94 runs sampled)
HIREDIS BUF:   + multiple chunks in a string x 953,733 ops/sec ±2.03% (82 runs sampled)
JS PARSER BUF: + multiple chunks in a string x 2,298,458 ops/sec ±0.79% (96 runs sampled)

HIREDIS:   $ 4mb bulk string x 152 ops/sec ±2.03% (72 runs sampled)
JS PARSER: $ 4mb bulk string x 971 ops/sec ±0.79% (86 runs sampled)
HIREDIS BUF:   $ 4mb bulk string x 169 ops/sec ±2.25% (71 runs sampled)
JS PARSER BUF: $ 4mb bulk string x 797 ops/sec ±7.08% (77 runs sampled)

HIREDIS:   + simple string x 3,341,956 ops/sec ±1.01% (94 runs sampled)
JS PARSER: + simple string x 5,979,545 ops/sec ±0.38% (96 runs sampled)
HIREDIS BUF: + simple string x 1,031,745 ops/sec ±2.17% (76 runs sampled)
JS PARSER BUF: + simple string x 6,960,184 ops/sec ±0.28% (93 runs sampled)

HIREDIS:   : integer x 3,897,626 ops/sec ±0.42% (91 runs sampled)
JS PARSER: : integer x 37,035,812 ops/sec ±0.32% (94 runs sampled)
JS PARSER STR: : integer x 25,515,070 ops/sec ±1.79% (83 runs sampled)

HIREDIS:   : big integer x 3,036,704 ops/sec ±0.47% (92 runs sampled)
JS PARSER: : big integer x 10,616,464 ops/sec ±0.94% (94 runs sampled)
JS PARSER STR: : big integer x 7,098,146 ops/sec ±0.47% (94 runs sampled)

HIREDIS:   * array x 51,542 ops/sec ±0.35% (94 runs sampled)
JS PARSER: * array x 87,090 ops/sec ±2.17% (94 runs sampled)
HIREDIS BUF:   * array x 11,733 ops/sec ±1.80% (80 runs sampled)
JS PARSER BUF: * array x 149,430 ops/sec ±1.50% (88 runs sampled)

HIREDIS:   * big nested array x 247 ops/sec ±0.93% (73 runs sampled)
JS PARSER: * big nested array x 286 ops/sec ±0.79% (83 runs sampled)
HIREDIS BUF:   * big nested array x 217 ops/sec ±1.80% (73 runs sampled)
JS PARSER BUF: * big nested array x 175 ops/sec ±2.49% (37 runs sampled)

HIREDIS:   - error x 108,110 ops/sec ±0.63% (84 runs sampled)
JS PARSER: - error x 172,665 ops/sec ±0.57% (85 runs sampled)

Platform info:
OSX 10.12.6
Node.js 10.0.0
Intel(R) Core(TM) i7-5600U CPU

License

MIT

node-redis-parser's People

Contributors

bridgear avatar ckarper avatar greenkeeper[bot] avatar jjofseattle avatar kikobeats avatar salakar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-redis-parser's Issues

Error: [email protected] install: `node-gyp rebuild`

the node-redis package fails to install because the devDependency "hiredis": "^0.5.0" fails to install

5255 verbose stack Error: [email protected] install: `node-gyp rebuild`
5255 verbose stack Exit status 1
5255 verbose stack     at EventEmitter.<anonymous> (/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/lib/node_modules/npm/lib/utils/lifecycle.js:214:16)
5255 verbose stack     at emitTwo (events.js:87:13)
5255 verbose stack     at EventEmitter.emit (events.js:172:7)
5255 verbose stack     at ChildProcess.<anonymous> (/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/lib/node_modules/npm/lib/utils/spawn.js:24:14)
5255 verbose stack     at emitTwo (events.js:87:13)
5255 verbose stack     at ChildProcess.emit (events.js:172:7)
5255 verbose stack     at maybeClose (internal/child_process.js:818:16)
5255 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
5256 verbose pkgid [email protected]
5257 verbose cwd /tmp/deployment/application
5258 error Linux 4.1.13-18.26.amzn1.x86_64
5259 error argv "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.2.3-linux-x64/bin/npm" "--production" "install"
5260 error node v4.2.3
5261 error npm  v2.14.7
5262 error code ELIFECYCLE
5263 error [email protected] install: `node-gyp rebuild`
5263 error Exit status 1
5264 error Failed at the [email protected] install script 'node-gyp rebuild'.
5264 error This is most likely a problem with the hiredis package,
5264 error not with npm itself.
5264 error Tell the author that this fails on your system:
5264 error     node-gyp rebuild
5264 error You can get their info via:
5264 error     npm owner ls hiredis
5264 error There is likely additional logging output above.
5265 verbose exit [ 1, true ]

Should hiredis dependency be in 'devDependencies'?

Hi! I'm using this package through the Bull npm package, and am getting some build warnings when requiring Bull in my app:

Unable to resolve some modules:

  "hiredis" in app/node_modules/redis-parser/lib/hiredis.js
(os.osx.x86_64)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save hiredis

(using Meteor, but I don't think that's relevant).

It seems like you're specifying your hiredis dependency as a devDependency, and then requiring it here, and thus the app fails to build, since it doesn't install dev dependencies?

Let me know if I'm off here.

An in-range update of mocha is breaking the build 🚨

Version 3.4.1 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.4.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes Ohai CRLF...

Fixed a publishing mishap with git's autocrlf settings.

Commits

The new version differs by 3 commits0.

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

RedisError is undefined

Hello,

in redis tests (lib/customErrors.js line 5), this value is undefined:

var RedisError = require('redis-parser').RedisError;

It seems that RedisError isn't inherited from redis-errors. So I'm unable to launch tests.

Cheers,
Xavier

ParserError: Protocol error, got "\r" as reply type byte. Please report this.

node:events:368
throw er; // Unhandled 'error' event
^

ParserError: Protocol error, got "\r" as reply type byte. Please report this.
at handleError (/Users/xxxx/xxxx/node_modules/redis-parser/lib/parser.js:190:15)
at parseType (/Users/xxxx/xxxx/node_modules/redis-parser/lib/parser.js:304:14)
Emitted 'error' event on RedisClient instance at:
at JavascriptRedisParser.returnFatalError (/Users/xxxx/xxxx/node_modules/redis/index.js:156:18)
at handleError (/Users/xxxx/xxxx/node_modules/redis-parser/lib/parser.js:196:10)
at parseType (/Users/xxxx/xxxx/node_modules/redis-parser/lib/parser.js:304:14)
at JavascriptRedisParser.execute (/Users/xxxx/xxxx/node_modules/redis-parser/lib/parser.js:533:24)
at Socket. (/Users/xxxx/xxxx/node_modules/redis/index.js:219:27)

TypeError: Cannot read property 'length' of null

Every now and then the error below occurs and crashes Node.
The specific circumstances which trigger it are unknown.

/opt/nodeapp/node_modules/redis-parser/lib/parser.js:560
  while (this.offset < this.buffer.length) {
                                   ^

TypeError: Cannot read property 'length' of null
    at JavascriptRedisParser.execute (/opt/nodeapp/node_modules/redis-parser/lib/parser.js:560:36)
    at Socket.<anonymous> (/opt/nodeapp/node_modules/redis/index.js:274:27)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:597:20)

Running node-redis 2.8.0 and thus node-redis-parser 2.6.0 on Node v8.8.1, AWS Linux

I see there's a node-redis-parser v3.0.0 which has made changes that may or not effect this error, but no updated version of node-redis to use it?

Error: Must have start <= end

Hello I get this error randomly
buffer.js:416 return this.parent.utf8Slice(start, end); ^ Error: Must have start <= end at Buffer.toString (buffer.js:416:26) at convertBufferRange (node_modules/redis-parser/lib/parser.js:80:24) at parseBulkString (node_modules/redis-parser/lib/parser.js:153:10) at parseType (node_modules/redis-parser/lib/parser.js:220:14) at parseArray (node_modules/redis-parser/lib/parser.js:201:20) at parseType (node_modules/redis-parser/lib/parser.js:226:14) at JavascriptRedisParser.execute (node_modules/redis-parser/lib/parser.js:421:20) at Socket.<anonymous> (node_modules/redis/index.js:267:27)
nodejs -v v0.10.37
redis 2.6.3
redis-parser 2.1.1

I don't have any details on the content of the data but the server crashed...

Large array lengths can cause an unhandled RangeError

I'm seeing an unhandled exception in cases where the parser is given invalid data that happens to contain something that looks like an array. Part of the problem is that the parser will preallocate an array using whatever length parameter was given (valid or not) as seen here. If length happens to be a very large positive number, then this will result in a RangeError being thrown.

You can test this by having the parser read this buffer: Buffer.from("2AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D0A", "hex"). Add more bytes and length will eventually go to Infinity.

Something should be done to at least handle the potential exception and treat it as a parsing error.

hiredis still listed as dependency in the NPM package [email protected]

As noted in the issue title, the package.json file obtained during installing this package via the npm command ...
npm i [email protected] OR npm i redis-parser@latest
... still contains a reference to the hiredis dependancy.

According to your change log (and actually from what I can see in your repo in latest version of master branch) this dependency has completely been removed.

Any plans to make the npm v3.0.0 package consistent with whats in your repo?

Cheers for the support.

Node engine needs to be updated

The major version should be bumped or at least the node engine version should be updated from >=0.10.0 to >0.12. This would warn us poor souls that continue to support apps that run old but still maintained NodeJS versions that we could have an issue and fail the installation in strict mode.

For those that are interested:
node_redis@>=2.6.2 + NodeJS 0.12.15 causes a memory leak that also seems to max out the CPU of the instance.

Protocol error, got "\"" as reply type byte

ReplyError: Protocol error, got "\"" as reply type byte. Please report this.
    at parseType (/my-directory/node_modules/redis-parser/lib/parser.js:224:34)
    at JavascriptRedisParser.execute (/my-directory/node_modules/redis-parser/lib/parser.js:404:20)

Redis version 3.2.0

Reply Error: MOVED

Hey guys, I'm trying to connect to redis using superlogin https://github.com/colinskow/superlogin/blob/ebd34450895e24e5f6ed81a5c23802c18da6786d/config.example.js

and they're using your package. I have a cluster setup on AWS and not a single host and when I try to connect, I get the error below:

{ ReplyError: MOVED 449 172.31.29.70:6379
    at parseError (/usr/src/app/node_modules/redis-parser/lib/parser.js:193:12)
    at parseType (/usr/src/app/node_modules/redis-parser/lib/parser.js:303:14)
  command: 'PSETEX',

Is this repo setup for clustering?

Big chunked arrays are slow

As we have to parse all the data again and again in case of arrays it's currently slow in case the user gets big arrays (lots of entries e.g. 200+ that are quite big e.g. 10mb+).

This can be addressed by caching the already parsed data and continuing by the last entry and adding more to the already existing array as soon as the part is complete.

ERR wrong number of arguments for 'get' command

  1. NodeJS - v12.10.0
  2. Node-redis - v2.8.0
  3. Redis-parser - v2.6.0

For the last couple of days, I have been getting this error. Sorry but I've got no other stacktrace. Unable to understand of why this is happening.

**Code - **

redisClient.get(this.key, function (err, res) {
    if (err) throw err;
    if (res) {}
}

Error -

ReplyError: ERR wrong number of arguments for 'get' command
        at parseError (/Users/Kaushik/dev/spiked.sh/escalations/node_modules/redis-parser/lib/parser.js:193:12)
        at parseType (/Users/Kaushik/dev/spiked.sh/escalations/node_modules/redis-parser/lib/parser.js:303:14)

What could be causing this?

Very critical bug in javascript parser 2.0.0+

Buffers are corrupted after sending one more command. Example:

var redis  = require('redis'),
    client = redis.createClient({return_buffers: true});

client.set('s1', 'a'.repeat(65527));
client.set('s2', 'b'.repeat(65527));

client.get('s1', function(err, buf) {
    console.log(buf[0]); //prints 97, it's OK

    client.get('s2', function() {
        console.log(buf[0]); //prints 98, but must print 97
    });
});

This is starting with javascript parser 2.0.0. The bug occurs when buffer.length >= 65527 (and in 50% cases when buffer.length >= 65517).

Example 2:

var redis  = require('redis'),
    client = redis.createClient({return_buffers: true});

client.set('s1', 'a'.repeat(65527));
client.set('s2', 'b'.repeat(65527));

client.get('s1', function(err, buf) {
    setImmediate(function() {
        console.log(buf[0]); //prints 98, but must print 97
    });
});
client.get('s2');

In the second example bug occurs only in javascript parser 2.0.1+ (not 2.0.0).

Socket.io adapter emitted error event: { ParserError: Protocol error, got "a" as reply type byte. Please report this.

verbo: Socket.io adapter emitted error event: { ParserError: Protocol error, got "a" as reply type byte. Please report this.
at parseType (/app/node_modules/redis-parser/lib/parser.js:305:34)
at JavascriptRedisParser.execute (/app/node_modules/redis-parser/lib/parser.js:563:20)
at Socket. (/app/node_modules/machinepack-redis/node_modules/redis/index.js:267:27)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at Socket.Readable.push (_stream_readable.js:218:10)
at TCP.onread (net.js:581:20)
offset: 138,
buffer: '{"type":"Buffer","data":[43,79,75,13,10,36,50,49,49,57,13,10,35,32,83,101,114,118,101,114,13,10,114,101,100,105,115,95,118,101,114,115,105,111,110,58,50,46,56,46,50,52,13,10,114,101,100,105,115,95,103,105,116,95,115,104,97,49,58,100,99,101,55,102,55,53,54,13,10,114,101,100,105,115,95,103,105,116,95,100,105,114,116,121,58,48,13,10,114,101,100,105,115,95,98,117,105,108,100,95,105,100,58,52,97,51,53,48,48,55,52,101,98,52,52,100,53,52,100,13,10,114,101,100,105,115,95,109,111,100,101,58,115,116,97,110,100,97,108,111,110,101,13,10,111,115,58,76,105,110,117,120,32,52,46,49,53,46,49,53,45,51,50,46,101,108,54,112,105,101,32,120,56,54,95,54,52,13,10,97,114,99,104,95,98,105,116,115,58,54,52,13,10,109,117,108,116,105,112,108,101,120,105,110,103,95,97,112,105,58,101,112,111,108,108,13,10,103,99,99,95,118,101,114,115,105,111,110,58,52,46,56,46,52,13,10,112,114,111,99,101,115,115,95,105,100,58,50,48,13,10,114,117,110,95,105,100,58,50,50,102,53,52,48,53,55,101,55,51,56,102,51,49,48,49,100,53,56,52,57,100,97,57,50,48,51,55,97,55,57,101,55,98,56,52,56,98,48,13,10,116,99,112,95,112,111,114,116,58,51,49,57,57,50,13,10,117,112,116,105,109,101,95,105,110,95,115,101,99,111,110,100,115,58,50,52,52,48,51,56,55,13,10,117,112,116,105,109,101,95,105,110,95,100,97,121,115,58,50,56,13,10,104,122,58,49,48,13,10,108,114,117,95,99,108,111,99,107,58,49,54,53,54,57,49,54,49,13,10,99,111,110,102,105,103,95,102,105,108,101,58,47,97,112,112,47,114,101,100,105,115,46,99,111,110,102,13,10,13,10,35,32,67,108,105,101,110,116,115,13,10,99,111,110,110,101,99,116,101,100,95,99,108,105,101,110,116,115,58,49,49,13,10,99,108,105,101,110,116,95,108,111,110,103,101,115,116,95,111,117,116,112,117,116,95,108,105,115,116,58,48,13,10,99,108,105,101,110,116,95,98,105,103,103,101,115,116,95,105,110,112,117,116,95,98,117,102,58,48,13,10,98,108,111,99,107,101,100,95,99,108,105,101,110,116,115,58,48,13,10,13,10,35,32,77,101,109,111,114,121,13,10,117,115,101,100,95,109,101,109,111,114,121,58,49,51,48,57,49,53,50,56,13,10,117,115,101,100,95,109,101,109,111,114,121,95,104,117,109,97,110,58,49,50,46,52,57,77,13,10,117,115,101,100,95,109,101,109,111,114,121,95,114,115,115,58,51,49,57,53,50,56,57,54,13,10,117,115,101,100,95,109,101,109,111,114,121,95,112,101,97,107,58,52,54,57,57,57,51,49,50,13,10,117,115,101,100,95,109,101,109,111,114,121,95,112,101,97,107,95,104,117,109,97,110,58,52,52,46,56,50,77,13,10,117,115,101,100,95,109,101,109,111,114,121,95,108,117,97,58,51,54,56,54,52,13,10,109,101,109,95,102,114,97,103,109,101,110,116,97,116,105,111,110,95,114,97,116,105,111,58,50,46,52,52,13,10,109,101,109,95,97,108,108,111,99,97,116,111,114,58,106,101,109,97,108,108,111,99,45,51,46,54,46,48,13,10,13,10,35,32,80,101,114,115,105,115,116,101,110,99,101,13,10,108,111,97,100,105,110,103,58,48,13,10,114,100,98,95,99,104,97,110,103,101,115,95,115,105,110,99,101,95,108,97,115,116,95,115,97,118,101,58,54,51,13,10,114,100,98,95,98,103,115,97,118,101,95,105,110,95,112,114,111,103,114,101,115,115,58,48,13,10,114,100,98,95,108,97,115,116,95,115,97,118,101,95,116,105,109,101,58,49,53,50,54,53,49,56,52,57,51,13,10,114,100,98,95,108,97,115,116,95,98,103,115,97,118,101,95,115,116,97,116,117,115,58,111,107,13,10,114,100,98,95,108,97,115,116,95,98,103,115,97,118,101,95,116,105,109,101,95,115,101,99,58,48,13,10,114,100,98,95,99,117,114,114,101,110,116,95,98,103,115,97,118,101,95,116,105,109,101,95,115,101,99,58,45,49,13,10,97,111,102,95,101,110,97,98,108,101,100,58,48,13,10,97,111,102,95,114,101,119,114,105,116,101,95,105,110,95,112,114,111,103,114,101,115,115,58,48,13,10,97,111,102,95,114,101,119,114,105,116,101,95,115,99,104,101,100,117,108,101,100,58,48,13,10,97,111,102,95,108,97,115,116,95,114,101,119,114,105,116,101,95,116,105,109,101,95,115,101,99,58,45,49,13,10,97,111,102,95,99,117,114,114,101,110,116,95,114,101,119,114,105,116,101,95,116,105,109,101,95,115,101,99,58,45,49,13,10,97,111,102,95,108,97,115,116,95,98,103,114,101,119,114,105,116,101,95,115,116,97,116,117,115,58,111,107,13,10,97,111,102,95,108,97,115,116,95,119,114,105,116,101,95,115,116,97,116,117,115,58,111,107,13,10,13,10,35,32,83,116,97,116,115,13,10,116,111,116,97,108,95,99,111,110,110,101,99,116,105,111,110,115,95,114,101,99,101,105,118,101,100,58,50,52,52,51,55,51,13,10,116,111,116,97,108,95,99,111,109,109,97,110,100,115,95,112,114,111,99,101,115,115,101,100,58,50,51,52,57,55,48,54,55,13,10,105,110,115,116,97,110,116,97,110,101,111,117,115,95,111,112,115,95,112,101,114,95,115,101,99,58,49,13,10,116,111,116,97,108,95,110,101,116,95,105,110,112,117,116,95,98,121,116,101,115,58,52,51,56,48,56,54,49,52,56,54,13,10,116,111,116,97,108,95,110,101,116,95,111,117,116,112,117,116,95,98,121,116,101,115,58,49,50,57,53,54,52,51,51,57,57,53,13,10,105,110,115,116,97,110,116,97,110,101,111,117,115,95,105,110,112,117,116,95,107,98,112,115,58,48,46,48,53,13,10,105,110,115,116,97,110,116,97,110,101,111,117,115,95,111,117,116,112,117,116,95,107,98,112,115,58,48,46,48,50,13,10,114,101,106,101,99,116,101,100,95,99,111,110,110,101,99,116,105,111,110,115,58,48,13,10,115,121,110,99,95,102,117,108,108,58,51,13,10,115,121,110,99,95,112,97,114,116,105,97,108,95,111,107,58,48,13,10,115,121,110,99,95,112,97,114,116,105,97,108,95,101,114,114,58,48,13,10,101,120,112,105,114,101,100,95,107,101,121,115,58,49,48,52,49,48,49,54,13,10,101,118,105,99,116,101,100,95,107,101,121,115,58,48,13,10,107,101,121,115,112,97,99,101,95,104,105,116,115,58,49,51,50,51,48,13,10,107,101,121,115,112,97,99,101,95,109,105,115,115,101,115,58,48,13,10,112,117,98,115,117,98,95,99,104,97,110,110,101,108,115,58,51,13,10,112,117,98,115,117,98,95,112,97,116,116,101,114,110,115,58,49,13,10,108,97,116,101,115,116,95,102,111,114,107,95,117,115,101,99,58,49,48,56,52,13,10,13,10,35,32,82,101,112,108,105,99,97,116,105,111,110,13,10,114,111,108,101,58,109,97,115,116,101,114,13,10,99,111,110,110,101,99,116,101,100,95,115,108,97,118,101,115,58,50,13,10,115,108,97,118,101,48,58,105,112,61,49,55,46,49,50,49,46,49,51,56,46,49,53,56,44,112,111,114,116,61,51,49,48,49,49,44,115,116,97,116,101,61,111,110,108,105,110,101,44,111,102,102,115,101,116,61,52,49,55,50,48,56,49,49,52,52,44,108,97,103,61,49,13,10,115,108,97,118,101,49,58,105,112,61,49,55,46,49,50,49,46,49,52,56,46,56,54,44,112,111,114,116,61,51,49,48,48,55,44,115,116,97,116,101,61,111,110,108,105,110,101,44,111,102,102,115,101,116,61,52,49,55,50,48,56,49,49,52,52,44,108,97,103,61,49,13,10,109,97,115,116,101,114,95,114,101,112,108,95,111,102,102,115,101,116,58,52,49,55,50,48,56,49,49,52,52,13,10,114,101,112,108,95,98,97,99,107,108,111,103,95,97,99,116,105,118,101,58,49,13,10,114,101,112,108,95,98,97,99,107,108,111,103,95,115,105,122,101,58,49,48,52,56,53,55,54,13,10,114,101,112,108,95,98,97,99,107,108,111,103,95,102,105,114,115,116,95,98,121,116,101,95,111,102,102,115,101,116,58,52,49,55,49,48,51,50,53,54,57,13,10,114,101,112,108,95,98,97,99,107,108,111,103,95,104,105,115,116,108,101,110,58,49,48,52,56,53,55,54,13,10,13,10,35,32,67,80,85,13,10,117,115,101,100,95,99,112,117,95,115,121,115,58,50,48,51,49,46,56,50,13,10,117,115,101,100,95,99,112,117,95,117,115,101,114,58,49,49,56,54,46,51,49,13,10,117,115,101,100,95,99,112,117,95,115,121,115,95,99,104,105,108,100,114,101,110,58,55,55,46,50,50,13,10,117,115,101,100,95,99,112,117,95,117,115,101,114,95,99,104,105,108,100,114,101,110,58,54,49,54,46,53,51,13,10,13,10,35,32,75,101,121,115,112,97,99,101,13,10,100,98,48,58,107,101,121,115,61,51,52,54,56,49,44,101,120,112,105,114,101,115,61,51,52,54,56,49,44,97,118,103,95,116,116,108,61,52,52,48,48,56,50,56,51,13,10,13,10]}' }

redis: 2.6.3
redis-parser 2.6.0

Publish 3.0.0?

Shouldn't 3.0.0 be published as a release so node-redis can use this update? (Finally fixing the can't find module hiredis error when using webpack)

TypeError on options argument

Currently receiving the following error:

TypeError: The options argument contains the property "extend" that is either unkown or of a wrong type

at new JavascriptRedisParser (/Users/travisn/git/MSCBMOPROD/mscbmoprod-node-api-public/node_modules/redis-parser/lib/parser.js:255:13)
    at create_parser (/Users/travisn/git/MSCBMOPROD/mscbmoprod-node-api-public/node_modules/redis/index.js:186:12)
    at new RedisClient (/Users/travisn/git/MSCBMOPROD/mscbmoprod-node-api-public/node_modules/redis/index.js:160:25)

Using
[email protected]
[email protected]

Able to reproduce using node 4.4.4 & 6.2.2.

Not sure where this extend property is coming from, any ideas?

Parsing Issue

There is some parsing issue which has started causing the following error since the new release:

SyntaxError: Use of const in strict mode. at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.cls_wrapMethod (/var/app/current/node_modules/newrelic/lib/shimmer.js:246:38) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/var/app/current/node_modules/redis/node_modules/redis-parser/index.js:3:18) at Module._compile (module.js:460:26) /var/app/current/node_modules/redis/node_modules/redis-parser/lib/parser.js:230 const err = new ReplyError('Protocol error, got ' + JSON.stringify(Strin

ERR invalid expire time in set

Hello,

I have a Node.js web application which uses redis as session storage. Some requests receive the following ReplyError while trying to save the session:

ReplyError: ERR invalid expire time in set
   at parseError (.../node_modules/redis-parser/lib/parser.js:179:12)
   at parseType (.../node_modules/redis-parser/lib/parser.js:302:14)

I checked the specified file but I couldn't find anything which might cause it. Also, as far as I know, set method doesn't receive a expire time argument. I would very much appreciate any pointers as to how to fix it or what may cause it.

OS: Ubuntu 18.04.1 LTS
NodeJS version: 12.19.0
redis-server version: 4.0.9
node-redis version: 3.0.2
node-redis-parser version: 3.0.0

TypeError: Cannot read property 'length' of null

Hi,

I'm using node 6.2.1 on ubuntu 16.04. With the latest release (2.0.2), I'm getting a bunch of errors (happening at random):

  while (this.offset < this.buffer.length) {
                                  ^

TypeError: Cannot read property 'length' of null
    at JavascriptRedisParser.execute (xxx/node_modules/redis-parser/lib/parser.js:396:35)
    at Socket.<anonymous> (xxx/node_modules/redis/index.js:267:27)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:542:20)

I reckon I don't know how to let you reproduce the problem, but still do you have any clue about what the problem could be? It looks like something in the logic that handles null buffers.

Thanks

redis-parser referring null values.

Hi, redis-parser.

I am developing a solution, and redis is an important part.
I can not trace what the reason is,
On my way to development, I noticed that redis-parser had a problem referring to null values.

Next time you release the patch, I want you to make sure the following variables have null values.

The error message looks like this:

/usr/src/app/node_modules/redis-parser/lib/parser.js:560
while (this.offset < this.buffer.length) {
^

TypeError: Cannot read property 'length' of null
at JavascriptRedisParser.execute (/usr/src/app/node_modules/redis-parser/lib/parser.js:560:35)
at Socket. (/usr/src/app/node_modules/redis/index.js:274:27)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)

I'll fix it like this:

  if(this.buffer !== null){
    while (this.offset < this.buffer.length) {
      var offset = this.offset
      var type = this.buffer[this.offset++]
      var response = parseType(this, type)
      if (response === undefined) {
        if (!this.arrayCache.length) {
          this.offset = offset
        }
        return
      }
  
      if (type === 45) {
        this.returnError(response)
      } else {
        this.returnReply(response)
      }
    }
  }

Thank you

SyntaxError: Use of const in strict mode.

Hi, we're still running some legacy code on node 0.10, a recent change has caused our services to fail with:

.../node_modules/redis/node_modules/redis-parser/lib/parser.js:230 const err = new ReplyError('Protocol error, got ' + JSON.stringify(Strin
     ^^^^^
SyntaxError: Use of const in strict mode.
 at Module._compile (module.js:439:25)
 at Object.Module._extensions..js (module.js:474:10)

using const with "use strict"; fails in node 0.10 / 0.12, yet node-parser's package.json still lists the minimum engine as node 0.10.

the crashing line was introduced in:

6c149ea#diff-3fab227e34d65fe9bb2d6ea53eec41cfR226

Could const either be removed, or the minimum engine requirements updated?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.