Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import type { SendCommandFn } from 'rate-limit-redis';
import { createClusterSafeSendCommand } from '../limiterSendCommand';
describe('createClusterSafeSendCommand', () => {
it('falls back to EVAL with the cached script when a cluster node returns NOSCRIPT', async () => {
const execute = jest.fn<ReturnType<SendCommandFn>, Parameters<SendCommandFn>>();
execute
.mockResolvedValueOnce('script-sha')
.mockRejectedValueOnce(new Error('NOSCRIPT No matching script. Please use EVAL.'))
.mockResolvedValueOnce([1, 60_000]);
const sendCommand = createClusterSafeSendCommand(execute);
const script = 'return redis.call("INCR", KEYS[1])';
await expect(sendCommand('SCRIPT', 'LOAD', script)).resolves.toBe('script-sha');
await expect(sendCommand('EVALSHA', 'script-sha', '1', 'limiter:key')).resolves.toEqual([
1, 60_000,
]);
expect(execute).toHaveBeenNthCalledWith(2, 'EVALSHA', 'script-sha', '1', 'limiter:key');
expect(execute).toHaveBeenNthCalledWith(3, 'EVAL', script, '1', 'limiter:key');
});
});