fix: cannot read private member by Eomm · Pull Request #3151 · redis/node-redis

Description

Here:

the error is totally ignored and it hides:

TypeError: Cannot read private member #clientSideCache from an object whose class did not declare it

To replicate it:

Given this simple snippet:

import { createClientPool } from '@redis/client';

const pool = createClientPool(
  { host: 'localhost', tls: false, port: 6379 },//
)

await pool.connect();
await pool.close();
console.debug('Closed')

console.debug({
  totalClients: pool.totalClients,
  idleClients: pool.idleClients,
  clientsInUse: pool.clientsInUse
})

It prints:

{ totalClients: 1, idleClients: 1, clientsInUse: 0 }

With the fix it prints:

{ totalClients: 0, idleClients: 0, clientsInUse: 0 }

Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?