question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ioredis won't throw errors, prints to console instead - Unhandled error event: Error: connect ECONNREFUSED

See original GitHub issue

Error handling seems to be broken when trying to query a non-existent database. To reproduce:

const Redis = require('ioredis');

const settings = {
  host: "localhost",
  port: 1234 // any invalid port
};

const redis = new Redis(settings);

(async function() {
  try {
    await redis.info()
  } catch (err) {
    // no error is caught, ioredis prints straight to console
    console.log("caught: ", err)
  }
})()

Results in console getting flooded with:

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)

Version 4.19.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:6

github_iconTop GitHub Comments

2reactions
peteraw77commented, Nov 10, 2020

The proposed solution in #1209 seemed to resolve this for me.

2reactions
peteraw77commented, Nov 10, 2020

Experiencing the same issue, tried passing a reconnectOnError function but no use

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ioredis] unhandled error event: error: connect econnrefused ...
luin/ioredisioredis won't throw errors, prints to console instead - Unhandled error event: Error: connect ECONNREFUSED#1235. Created about 2 years ago.
Read more >
node.js - Unable to handle this error gracefully - Stack Overflow
I tried to put my code in try catch but unfortunately redis is not throwing exception and unable to catch the exception in...
Read more >
AWS Lambda function errors in Node.js
This page describes how to view Lambda function invocation errors for the Node.js runtime using the Lambda console and the AWS CLI.
Read more >
Redis with Node.js (ioredis) | Redis Documentation Center
This example shows how to configure ioredis to make a connection to Redis using TLS ... [ioredis] Unhandled error event: ReplyError: NOPERM this...
Read more >
nodejs-api/ errors
console.error(err); }); connection.pipe(process.stdout);. A handful of typically asynchronous methods in the Node.js API may ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found