Socket
Socket
Sign inDemoInstall

redis-parser

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-parser - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

changelog.md

5

lib/hiredis.js

@@ -7,2 +7,3 @@ 'use strict';

this.name = 'hiredis';
this.returnBuffers = returnBuffers;
this.reader = new hiredis.Reader({

@@ -18,2 +19,6 @@ return_buffers: returnBuffers

// Protocol errors land here
// Reset the parser. Otherwise new commands can't be processed properly
this.reader = new hiredis.Reader({
return_buffers: this.returnBuffers
});
this.returnFatalError(err);

@@ -20,0 +25,0 @@ return void 0;

2

package.json
{
"name": "redis-parser",
"version": "1.0.0",
"version": "1.1.0",
"description": "Javascript Redis protocol (RESP) parser",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -93,2 +93,7 @@ [![Build Status](https://travis-ci.org/NodeRedis/node-redis-parser.png?branch=master)](https://travis-ci.org/NodeRedis/node-redis-parser)

## Protocol errors
To handle protocol errors (this is very unlikely to happen) gracefuly 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.
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

@@ -95,0 +100,0 @@

@@ -96,7 +96,9 @@ 'use strict';

it('parser error v2', function () {
it('parser error resets the buffer', function () {
var replyCount = 0;
var errCount = 0;
function checkReply (reply) {
assert.strictEqual(reply[0], 'OK');
assert.strictEqual(reply.length, 1);
assert(Buffer.isBuffer(reply[0]));
assert.strictEqual(reply[0].toString(), 'CCC');
replyCount++;

@@ -112,8 +114,12 @@ }

returnFatalError: checkError,
name: parserName
name: parserName,
returnBuffers: true
});
parser.execute(new Buffer('*1\r\n+OK\r\nb$1`zasd\r\na'));
// The chunk contains valid data after the protocol error
parser.execute(new Buffer('*1\r\n+CCC\r\nb$1\r\nz\r\n+abc\r\n'));
assert.strictEqual(replyCount, 1);
assert.strictEqual(errCount, 1);
parser.execute(new Buffer('*1\r\n+CCC\r\n'));
assert.strictEqual(replyCount, 2);
});

@@ -120,0 +126,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc