-
Notifications
You must be signed in to change notification settings - Fork 131
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
TS2322: Type 'Redis' is not assignable to type 'RedisClient'. #559
Comments
unfortunately this is because of no ioredis 5 support, if you use ioredis@4.28.5 it should work. hopefully this lib isn't dead, as I need ioredis 5.. |
its same issue sir.I coudnt solve this issue for a few months.and my depencies ; "private": true, |
I'm not sure then, the only real differences I see in your deps are a few versions older on things like: I'm also using the ptc-org fork of nestjs-query as its actively maintained, but I don't think that's your issue. my provider class that's working with graphql-redis-subscriptions 2.5.0 and ioredis 4.28.5 is below, but it's basically the same (I inject config, and have a date reviver so updatedAt timestamps work).. so not sure it'll help. import { Provider } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { pubSubToken } from '@ptc-org/nestjs-query-graphql';
import { RedisPubSub } from 'graphql-redis-subscriptions';
import Redis from 'ioredis';
export class RedisPubSubProvider {
static provider(): Provider {
return {
provide: pubSubToken(),
inject: [ConfigService],
useFactory: async (config: ConfigService) => {
const dateReviver = (key, value) => {
const isISO8601Z = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/;
if (typeof value === 'string' && isISO8601Z.test(value)) {
const tempDateNumber = Date.parse(value);
if (!isNaN(tempDateNumber)) {
return new Date(tempDateNumber);
}
}
return value;
};
const redisOptions = {
sentinels: config.get<boolean>('SENTINEL_ENABLED')
? [
{
host: config.get('REDIS_HOST'),
port: config.get('REDIS_PORT'),
},
]
: undefined,
host: config.get<boolean>('SENTINEL_ENABLED') ? undefined : config.get('REDIS_HOST'),
password: config.get('REDIS_PASSWORD'),
sentinelPassword: config.get<boolean>('SENTINEL_ENABLED')
? config.get('REDIS_PASSWORD')
: undefined,
name: config.get<boolean>('SENTINEL_ENABLED') ? 'mymaster' : undefined,
};
return new RedisPubSub({
publisher: new Redis(redisOptions),
subscriber: new Redis(redisOptions),
reviver: dateReviver,
});
},
};
}
} |
after updating from ioredis 5.2.4 to 5.3.1 i got the same error. |
I am also getting the same error on package update. Hence stuck for now with the older ioredis. |
The only way working out for me is to force the The breaking changes from v5.0.0 does not seem to be an issue, or so far I never got to see it. |
Hi @davidyaha can you please pin the ioredis dependency in Package.json to a verion that works? |
my redis-pub-sub.provider.ts like below ;
and error like ;
The text was updated successfully, but these errors were encountered: