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

[throttler-storage-redis] ERR invalid expire time in 'set' #55

Open
CzarOfScripts opened this issue Jan 13, 2025 · 0 comments
Open

[throttler-storage-redis] ERR invalid expire time in 'set' #55

CzarOfScripts opened this issue Jan 13, 2025 · 0 comments

Comments

@CzarOfScripts
Copy link

After I make any query, I get an error:

[Nest] 25764 - 01/13/2025, 4:56:28 AM ERROR [ExceptionsHandler] ERR invalid expire time in 'set' command script: f1e0da9c495676ab6904eb80db1f2811d5347f58, on @user_script:18.
ReplyError: ERR invalid expire time in 'set' command script: f1e0da9c495676ab6904eb80db1f2811d5347f58, on @user_script:18.
at parseError (F:\Project\NodeJS\work-projects\biosphere\backend\node_modules\redis-parser\lib\parser.js:179:12)
at parseType (F:\Project\NodeJS\work-projects\biosphere\backend\node_modules\redis-parser\lib\parser.js:302:14)

app.module imports:

ThrottlerModule.forRootAsync({
	imports: [ RedisModule ],
	inject: [ "REDIS_CONNECTION" ],
	async useFactory(redisConnection: Redis)
	{
		return {
			throttlers: [ { ttl: 0, limit: 0 } ],
			storage: new ThrottlerStorageRedisService(
				new Redis({
					host: redisConnection.options.host,
					port: redisConnection.options.port,
					keyPrefix: "throttle:"
				})
			),

			errorMessage(context, details)
			{
				throw new ThrottleException(details.timeToExpire);
			}
		};
	}
}),

RedisModule:

import { Module } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import type { IRedisConfig } from "config/configuration.types";
import Redis from "ioredis";

@Module({
	providers: [
		{
			provide: "REDIS_CONNECTION",
			async useFactory(configService: ConfigService)
			{
				const { host, port } = configService.get<IRedisConfig>("redis");

				return new Redis({ host, port, maxRetriesPerRequest: null });
			},
			inject: [ ConfigService ]
		}
	],
	exports: [ "REDIS_CONNECTION" ]
})
export class RedisModule { }
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

No branches or pull requests

1 participant