Skip to content

Migrate redis from v3 to v6 - #503

Merged
Nikoklis merged 1 commit into
masterfrom
redis-v6-migration
Aug 6, 2026
Merged

Migrate redis from v3 to v6#503
Nikoklis merged 1 commit into
masterfrom
redis-v6-migration

Conversation

@Nikoklis

@Nikoklis Nikoklis commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Replaces #490. That bump cannot be merged as-is: node-redis v4 rewrote the client API and the build fails. This PR does the actual migration.

Before / after

Client usage (breaking for orka consumers):

// before (v3, callbacks)
getRedis().get('key', (err, value) => { ... });

// after (v6, promises)
const value = await getRedis().get('key');

config.redis schema: unchanged. url, options.tls and the legacy retry/keepalive options (timesConnected, totalRetryTime, reconnectAfterMultiplier, socketKeepalive, socketInitialDelay) keep working and are mapped to the new driver options. Any other key in config.redis.options (e.g. RESP, pingInterval, socket) is passed through to createClient.

Initializer internals:

before (v3) after (v6)
Client creation createClient(url, options) createClient({ url, RESP: 2, socket })
Connection implicit explicit client.connect(), awaited during boot; if redis is down the app still boots and /health reports unhealthy
Reconnect retry_strategy socket.reconnectStrategy, same semantics
Too many reconnects thrown error crashed the process stops reconnecting; /health turns 503 so the orchestrator restarts the pod
Health check client.connected client.isReady
Keep-alive manual setKeepAlive on client.stream socket.keepAlive / socket.keepAliveInitialDelay
Close (tests) client.end(true) client.destroy()
Types @types/redis shipped with the driver (@types/redis removed)

RESP is pinned to 2 to preserve reply shapes; set config.redis.options.RESP = 3 to opt in to RESP3.

Breaking changes

  • getRedis() returns a promise-based node-redis v6 client; callback-style commands and client.end() are gone.
  • createRedisConnection() is now async and resolves after the initial connection attempt.
  • node-redis v6 requires Node >= 20 (CI matrix already is 20/22/24).
  • Requires a major orka release.

Testing

  • Unit tests rewritten for the new API (option mapping, TLS, all reconnect-strategy branches).
  • Redis example e2e passes against a real redis: connect, /health 200, destroy(), /health 503.
  • Manual smoke test of set/get/del through getRedis().

🤖 Generated with Claude Code

node-redis v4 rewrote the client API (promise-based commands, explicit
connect(), createClient(options) signature, socket-level reconnect
strategy) and v6 made RESP3 the default protocol. This migrates the
redis initializer while keeping the orka config schema unchanged:

- createClient({url, socket}) with the legacy options (timesConnected,
  totalRetryTime, reconnectAfterMultiplier, socketKeepalive,
  socketInitialDelay, tls) mapped to socket options and a
  reconnectStrategy that preserves the old retry_strategy semantics;
  the old "throw to crash the server" case now stops reconnecting so
  the health check reports unhealthy instead
- the initial connect() is awaited during boot so the client is ready
  before the server listens; a failed connection is only logged and
  the app still boots with /health reporting unhealthy
- isHealthy() uses isReady instead of the removed connected property
- RESP is pinned to 2 to preserve reply shapes; override via
  config.redis.options.RESP
- remove obsolete @types/redis; v6 ships its own types

BREAKING CHANGE: getRedis() now returns a promise-based node-redis v6
client; callback-style commands and client.end() are gone.
createRedisConnection() is now async. Requires a major orka release.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nikoklis
Nikoklis force-pushed the redis-v6-migration branch from d6d63d2 to 0362c9b Compare August 6, 2026 08:50
@Nikoklis
Nikoklis marked this pull request as ready for review August 6, 2026 08:56

@klesgidis klesgidis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! maybe we should give it a try before releasing this

@Nikoklis

Nikoklis commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Will merge and get a new rc tag from master and test it.

@Nikoklis
Nikoklis merged commit 3188a18 into master Aug 6, 2026
14 checks passed
@Nikoklis
Nikoklis deleted the redis-v6-migration branch August 6, 2026 13:21
This was referenced Aug 6, 2026
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

Successfully merging this pull request may close these issues.

4 participants