fix(jwt): detect the redis client correctly and branch markUsed on it - #28
Merged
Conversation
The store picked its dialect from `client.constructor.name`, matching only 'Redis' or 'Cluster'. A real ioredis instance reports 'EventEmitter' — it extends EventEmitter and no class name survives to the instance — so the probe never matched and every ioredis client was treated as node-redis, sending `SET key value [object Object]`. `markUsed` had a second, independent defect: it never consulted the detected dialect and always used the ioredis positional `eval` form. node-redis does not reject that call, it sends `EVAL <script> 0`, so the script ran against an empty KEYS and failed inside Redis. Between the two, the blacklist and the RFC 6749 §10.4 refresh-reuse registry were unusable on every supported client. Detection now probes the API surface (`scanStream` / `status`) as paseto's store already did, and `markUsed` branches like its neighbours. Also seeds the `deleteAll` SCAN cursor as a string. node-redis typed cursors as numbers through v5 but requires a string from v6, and the peer range (`>=4.0.0`) admits v6. The integration suite's todo markers are lifted and it now covers deleteAll, which had no live-Redis coverage at all.
ExorTek
force-pushed
the
fix/jwt-redis-dialect
branch
from
August 6, 2026 09:14
7650adc to
713d9e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #27 — merge that first.
@exortek/jwt@1.2.2's Redis store does not work with any supported client. Two independent defects:client.constructor.name, accepting only'Redis'or'Cluster'. A real ioredis instance reports'EventEmitter'on both v5 and v6, so every ioredis client was treated as node-redis andadd()sentSET key value [object Object].markUsedignored the detected dialect and always used the ioredis positionalevalform. node-redis does not reject that — it sendsEVAL <script> 0, so the script ran against an emptyKEYSand failed inside Redis.Between them, the blacklist and the RFC 6749 §10.4 refresh-reuse registry were unusable on Redis.
Detection now probes the API surface (
scanStream/status), as paseto's store already did — that fix was made there and never brought across.markUsedbranches like its neighbours.deleteAllalso seeds itsSCANcursor as a string, which node-redis requires from v6 and the peer range admits.Measured against the published package via its public entrypoint
add()→ERR syntax errormarkUsed()→ Lua arg errorThe integration suite's todo markers are lifted, and it now covers
deleteAll, which had no live-Redis coverage at all.