Skip to content

feat: add redis driver identification - #320

Open
vchomakov wants to merge 10 commits into
fastify:mainfrom
vchomakov:feat/redis-driver-identification
Open

vchomakov wants to merge 10 commits into
fastify:mainfrom
vchomakov:feat/redis-driver-identification

Conversation

@vchomakov

@vchomakov vchomakov commented Jan 29, 2026 •

Copy link
Copy Markdown

Description

This PR adds Redis driver identification support using the CLIENT SETINFO command, which helps Redis server administrators identify connections from the @fastify/session library.

Changes

  • Added getDefaultClientInfoTag() function that returns a version-tagged identifier (e.g., fastify-session_v11.1.1)
  • Updated all Redis client instantiations in examples and benchmarks to use clientInfoTag
  • Added TypeScript type definitions and tests
  • Added comprehensive unit tests for the new functionality
  • Reads the version from a generated lib/version.js instead of package.json at runtime (bundler-safe); scripts/generate-version.js runs on the npm version hook and on prepack, and test/version.test.js fails if the file drifts from package.json
  • Documented in the README under the store option (node-redis example; ioredis takes the same option)

Benefits

  • Improves observability for Redis administrators
  • Follows Redis best practices for client identification
  • Helps with debugging and monitoring in production environments

Related


Checklist

Comment thread lib/fastifySession.js Resolved
@vchomakov
vchomakov requested a review from mcollina April 2, 2026 11:48
@vchomakov

Copy link
Copy Markdown
Author

@mcollina I have addressed your comments and would appreciate a review. Thanks!

vchomakov added 5 commits May 15, 2026 18:43
…ntification

# Conflicts:
#	types/types.test-d.ts
Regenerate lib/version.js for 11.1.6 and run the generator from the npm
"version" lifecycle hook, so the release workflow's `npm version` bump
updates it and stages it (git add -u) together with package.json.
@vchomakov

Copy link
Copy Markdown
Author

@mcollina this is rebased on main after the switch to node-redis (#347): the example and the benchmark now pass clientInfoTag to createClient(), and the type test only asserts the new export.

On your review comment: the version comes from a generated lib/version.js (no package.json read at runtime), with test/version.test.js failing if it drifts from package.json, like Fastify's test/build/version.test.js. The generator is also wired to the npm version lifecycle hook, so the release workflow's npm version bump regenerates the file and git add -u stages it into the release commit, no manual step.

Lint, the 149 unit tests at 100% coverage and the tstyche run all pass locally. Could you approve the CI run and take another look? Thanks!

This branch has not been deployed

No deployments
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.

2 participants