Skip to content

RedisClient : Bun Application Stuck During Execution of RedisClient.connect() Function #2630

@bong-u

Description

@bong-u

Description

My bun application gets stuck when executing the function RedisClient.connect().
I want to catch the error immediately upon failure.
But, It throws an error after about 2 minutes.
Additionally, this issue only occurs when a request is made to a URL that does not respond, not to a non-existent URL.

I also think that 2 minutes is too long to wait before an error is thrown. Is there a way to adjust this interval?

I'm not sure if this issue also occurs in a Node environment.

Here's the code:

import { createClient } from "redis";
import { logger } from "../config/winston";

const redis_client = await createClient({
  url: "redis://172.0.0.4:6379", // This URL does not respond.
}).on("error", (err: Error) => {
  logger.error(`Redis client error`);
  throw err;
});

logger.info("Connecting to redis client..."); // This works
await redis_client.connect().catch((err: Error) => { // Gets stuck here
  logger.error(err);
  throw err;
});
logger.info("Redis client connected"); // This doesn't execute

The logs are provided at the very bottom.

Node.js Version

Bun 1.0.3

Redis Server Version

7.2.1

Node Redis Version

4.6.10

Platform

Alpine linux 3.18.3

Logs

2023-10-17 04:48:54 info: Connecting to redis client...
2023-10-17 04:51:04 error: Redis client error
2023-10-17 04:51:04 error: undefined
ECONNREFUSED: Failed to connect
 syscall: "connect"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions