Skip to content

Node.js process crushes if a user has no permissions to run the 'monitor' command #1498

@artyom-podymov

Description

@artyom-podymov
  1. If create a user that has no permissions to run the monitor command
$ redis-cli 
localhost:6379> ACL SETUSER alice on nopass ~* &* +@all -monitor
OK
  1. Connect to Redis and call monitor function
const Redis = require("ioredis");

var redis = new Redis({host: 'localhost', port: 6379, username: 'alice'});

redis.on("connect", () => {
  console.log('Connected to DB \n');
  redis.monitor((err, monitor) => {
    console.log('Error', err)
    if (!err) {
      monitor.on('monitor', (...args) => console.log(JSON.stringify(args)))
    }
  });
});
  1. As a result in the callback function we don't see any error and Node.js process just crushes (the same behavior for async function implementation)
Connected to DB 

Error null                                                                                    
node_modules\redis-parser\lib\parser.js:179    
    return new ReplyError(string)                                                             
           ^                                                                                  
                                                                                              
ReplyError: NOPERM this user has no permissions to run the 'monitor' command or its subcommand
    at parseError (node_modules\redis-parser\lib\parser.js:179:12)
    at parseType (node_modules\redis-parser\lib\parser.js:302:14) {
  command: { name: 'monitor', args: [] }
}

Is it possible to handle such cases and properly throw errors without stopping the Node.js process?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions