Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda