-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Node.js process crushes if a user has no permissions to run the 'monitor' command #1498
Comments
Attach an event handler to the node.js process like this
Just include it anywhere in the global scope of your file (i.e. not inside any function or class). |
@udochify Thanks. But this approach looks like a workaround and I think such cases should be handled on the ioredis side. |
ok. Have you tried putting the part where you call monitor in a try catch block, like this? const Redis = require("ioredis");
var redis = new Redis({host: 'localhost', port: 6379, username: 'alice'});
redis.on("connect", () => {
console.log('Connected to DB \n');
try {
redis.monitor((err, monitor) => {
console.log('Error', err) // You only logged error here (and if the call to monitor completes). What if the call to monitor never starts as in your case
if (!err) {
monitor.on('monitor', (...args) => console.log(JSON.stringify(args)))
}
});
} catch (error) { // you caught and handled the error here
console.error("Redis Client Monitor Exception ", error);
}
}); Usually, catching errors (and not just logging them to the console) handles them and allows execution to continue. Same thing goes when you use async-await syntax async function foo () {
await redis.monitor(...).catch((error) => console.error(error));
} |
@udochify Yes, I tried) it doesn't help, the error does not fall into the catch block |
@udochify By the way, did you manage to reproduce this issue? Or maybe it's just me having this problem? |
## [5.0.3](v5.0.2...v5.0.3) (2022-03-31) ### Bug Fixes * add named exports to keep compatible with @types/ioredis ([#1552](#1552)) ([a89a900](a89a900)) * Fix failover detector with sentinel and tls streams ([ac00a00](ac00a00)) * handle NOPERM error for monitor ([93b873d](93b873d)), closes [#1498](#1498) * Hook up the keepAlive after a successful connect ([14f03a4](14f03a4)), closes [#1339](#1339)
🎉 This issue has been resolved in version 5.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [5.0.3](redis/ioredis@v5.0.2...v5.0.3) (2022-03-31) ### Bug Fixes * add named exports to keep compatible with @types/ioredis ([#1552](redis/ioredis#1552)) ([a89a900](redis/ioredis@a89a900)) * Fix failover detector with sentinel and tls streams ([ac00a00](redis/ioredis@ac00a00)) * handle NOPERM error for monitor ([93b873d](redis/ioredis@93b873d)), closes [#1498](redis/ioredis#1498) * Hook up the keepAlive after a successful connect ([14f03a4](redis/ioredis@14f03a4)), closes [#1339](redis/ioredis#1339)
monitor
commandasync
function implementation)Is it possible to handle such cases and properly throw errors without stopping the Node.js process?
The text was updated successfully, but these errors were encountered: