Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
Error being thrown on reconnection after disconnection in node-redis client

I couldn't understand what's the reason for the SocketClosedUnexpectedlyError error fired in the code below:

const redisClient = require('redis').createClient();

redisClient.connect().then(function() {
  return redisClient.disconnect();
})
.then(function() {
  redisClient.connect();
});

If I wrap the second redisClient.connect() call inside a setTimeout() call, as shown below, the error seems to go away:

const redisClient = require('redis').createClient();

redisClient.connect().then(function() {
  return redisClient.disconnect();
})
.then(function() {
  setTimeout(function() {
    redisClient.connect();
  }, 0);
});

Can anyone please explain what's the reason for the error thrown above? The documentation of @node-redis isn't good enough to explain this.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's a bug in node-redis v4...

https://github.com/redis/node-redis/issues/1801

https://github.com/redis/node-redis/commit/74daee302338cf2fcc1bb48aeac02be828e0c6d7

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!