byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

[BUG] RedisBackend connection always times out (lazyConnect never triggers) and lacks support for STORAGE_CACHE_USERNAME

Open WakeUp-Jin opened this issue 1 year ago • 3 comments

Bug Description

RedisBackend.connect() always throws a 1 s timeout because it forces lazyConnect: true but never explicitly starts the handshake.
Additionally, .env lacks STORAGE_CACHE_USERNAME, so Redis ACL username cannot be provided via environment variables.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Clone the repo and install dependencies
git clone https://github.com/campfirein/cipher.git
cd cipher && pnpm i
  1. Create a minimal repro minimal-repro.ts
import { RedisBackend } from '@/storage/backend/redis-backend'

const redis = new RedisBackend({
  type: 'redis',
  host: '127.0.0.1',
  port: 6379,
  database: 0,
  options: { username: 'default' }   // show username need
})

await redis.connect()                // will timeout after 1 s
  1. Run it
npx tsx minimal-repro.ts

  1. Observe Redis connection failed: timeout in console.

Expected Behavior

  • await redis.connect() should establish the connection and emit ready within a reasonable (and configurable) timeout.

  • Username should be configurable via STORAGE_CACHE_USERNAME, analogous to STORAGE_CACHE_PASSWORD.

Actual Behavior

  • Always throws Redis connection failed: timeout.

  • Username can only be hard-coded through options.username.

Screenshots

N/A (CLI reproduction is sufficient).

Environment Information

  • OS: macOS
  • Node.js version:v23.5.0
  • pnpm version:10.0.0
  • Redis version:7.2.6

Logs and Error Messages

⏳ connecting …
❌ Error: Error: Redis connection failed: timeout
    at Timeout._onTimeout (../cipher/src/core/storage/backend/redis-backend.ts:126:13)
    at listOnTimeout (node:internal/timers:614:17)
    at process.processTimers (node:internal/timers:549:7)

Additional Context

While reading and debugging the code I noticed:

  • lazyConnect is true but this.redis.connect() is never called, so the handshake never starts.
  • The hard-coded 1 s timer means any delay is treated as a failure.
  • .env.example lacks a username field, and the config loader doesn’t read it.

Possible Solution

  1. Call this.redis.connect() inside RedisBackend.connect() or default lazyConnect to false.

  2. Add STORAGE_CACHE_USERNAME to .env and inject it via options.username.

  3. Make the connection timeout configurable (e.g., REDIS_CONNECT_TIMEOUT_MS).

Checklist

  • [✓] I have searched for similar issues before creating this one
  • [ ✓] I have provided all the requested information above
  • [ x ] I have tested this on the latest version

Thanks for the awesome project — I’m really enjoying reading the code and experimenting with Cipher. Looking forward to your feedback! 🙌

WakeUp-Jin avatar Aug 02 '25 15:08 WakeUp-Jin

thanks for your report issue. I'll tackle this in day

billcache avatar Aug 03 '25 13:08 billcache

@WakeUp-Jin Please check out our latest commit to see if your issue has been fixed!

RyanNg1403 avatar Aug 06 '25 17:08 RyanNg1403

@WakeUp-Jin I'll close this issue. Feel free to reopen it if you have any problem!

RyanNg1403 avatar Aug 07 '25 18:08 RyanNg1403