redis / node-redis

Redis Node.js client

Home Page:https://redis.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

redis client legacy v4 API uses callbacks instead of promises

aleissner opened this issue · comments

Description

Using @redis/client with legacy mode, I can no longer access the v4 promise API.
Calling set or get function under v4 gives me callback functions.

` const client = createClient({ legacyMode: true });

client.on('error', err => console.log('Redis Client Error', err));

// @ts-ignore
await client.connect();

await client.v4.set('key', 'value', () => { console.log('callback') });
const value = await client.v4.get('key');
console.log('test value', value);
client.v4.get('key', (err, val) => { console.log('callback get', err, val); }

// @ts-ignore
await client.disconnect();`

Node.js Version

18.11

Redis Server Version

7.0.5

Node Redis Version

@redis/client 1.5.4

Platform

macOS

Logs

No response

I'm actually not sure why the tests didn't catch this, checking now... Sorry about that.

The tests only tested .v4.sendCommand... 🤦‍♂️
Ok, I found the issue, working on a fix (+ I'll add a test to make sure it won't happen again) now

redis@4.6.4/@redis/client@1.5.5 is on npm 🎉