Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix :too many client creation #2

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

fix :too many client creation #2

wants to merge 1 commit into from

Conversation

ujisi
Copy link

@ujisi ujisi commented Aug 29, 2023

If redis is not available, then Factory.create will be rejected, and generic-pool try to re-create the client. As a result, too many clients are created in heap. When redis becomes available, these clients can take all the free connections.

Steps for reproduce:

  1. stop redis server
  2. create pool
  3. subscribe on event 'error'
  4. call getConnection()

Sample code:

const poolOptions = {
    host: "127.0.0.1",
    port: "6379",
};
const redisPool = new RedisPool(poolOptions);

redisPool.on('error', (e, client) => {
  console.log(`error: ${e.message}`);
});

const client = redisPool.getConnection()
    .then(() => console.log('client create'))
    .catch(e => console.error(`client error: ${e.message}`));

@ujisi ujisi changed the title fix :too many createing clients fix :too many client creation Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant