ITADN

ERR syntax error caused by invalid arguments when ttl is enabled in connect-redis

#433Opentrelea 创建于 2025-06-18
T
treleacommented
### ERR syntax error caused by invalid arguments when ttl is enabled in connect-redis Summary: When using connect-redis with TTL enabled (default behavior), the library sometimes sends invalid arguments to Redis commands such as SET. This leads to Redis ERR syntax error failures. Details: The Redis command SET expects arguments like SET key value EX seconds (to set expiry in seconds). Internally, connect-redis attempts to set the TTL by adding expiry options (EX, PX) based on the ttl or session cookie maxAge. However, due to a bug or mismatch in how arguments are constructed or passed, the Redis client receives an [object Object] or malformed parameter instead of a valid TTL number. This results in errors similar to: ``` ReplyError: ERR syntax error at parseError (...redis-parser...) command: { name: 'set', args: [ 'session:key', '{"cookie":{...},"data":...}', '[object Object]' ] } ``` ![Image](https://github.com/user-attachments/assets/d928ad7b-2960-477d-ab87-f40fe4a01411) ![Image](https://github.com/user-attachments/assets/b27d7d5f-cb39-4bc1-bddf-ca8237763541)
3 条评论