Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:36:24+00:00 2026-06-11T00:36:24+00:00

The code in question: app.js var redis = require(‘redis’); var redisClient = redis.createClient(); redisClient.on(‘error’,

  • 0

The code in question: app.js

var redis = require('redis');
var redisClient = redis.createClient();
redisClient.on('error', function (err) {
  console.error('There was an Error ' + err);
});

// do stuff

redisClient.quit(function(err, res) {
  console.log('closing redis client.');
});

I’m trying to use node_redis to connect to Redis from my node.js app. However, I’m not too sure how to handle the case where Redis is down.

I’ve got a bunch of client.on('error', function(err) {})‘s but they never seem to be called. Is that the proper way to handle it? Am I calling it wrong?

I’ve just started using redis/node/express, so please excuse my ignorance.

EDIT As Vadim helped me realize, it seems that I am actually properly catching the error with client.on('error') in app.js. However, it’s my routes that cannot catch the errors when redis is down.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:36:25+00:00Added an answer on June 11, 2026 at 12:36 am

    Since node_redis is asynchronous, the redisClient.on('error') callback isn’t being called in time before I started to send other commands to redisClient.

    The way I fixed this issue was by putting “success” code in the redisClient.on('connect') handler, which would only be called after redisClient has successfully connected. And my fallback code in redisClient.on('error').

    You can see more about how I fixed this problem in this github changeset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically the question is how do I run gpgpu code in a Metro app.
I have this code in a JavaScript function: var url = '@Url.Action(MVC.Membership.User.ActionNames.Update, MVC.Membership.User.Name)'; url
I have the following code in both a C# console app and a C#
I have created a quiz app using XML. My XML code: <item> <question type=singleChoice>
Code to replicate In my app I have the following code. var seed =
This isn't a code question for once, but it definitely has me confused. Basically,
This is more of a licencing issue than a code question. I really like
In answering this code golf question , I ran across a problem in my
This is a code review question more then anything. I have the following problem:
Here is the code in question: import wx class MyFrame(wx.Frame): This is MyFrame. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.