fix(client): GETEX PXAT with Date must encode milliseconds#3317
Merged
Conversation
The modern { type: 'PXAT', value: Date } branch of GETEX routed through
transformEXAT, which floors the timestamp to seconds. PXAT expects a
millisecond Unix timestamp, so a Date was sent ~1000x too small and Redis
treated it as an already-elapsed expiry, immediately deleting the key.
Route PXAT through transformPXAT (milliseconds); EXAT still uses seconds.
nkaradzhov
approved these changes
Jul 2, 2026
nkaradzhov
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @spokodev, this looks good!
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.
Description
GETEXwith the modern{ type: 'PXAT', value: Date }option encodes the expiry in seconds instead of milliseconds.In
parseCommand,EXATandPXATshared a singleswitchcase that ran both throughtransformEXAT, which doesMath.floor(date.getTime() / 1000).PXATis the millisecond absolute-timestamp variant, so aDateis sent about 1000x too small. Redis reads that number as a millisecond timestamp far in the past and deletes the key immediately instead of extending its TTL.For a numeric
valuethere is no visible difference (both transforms pass a number straight through), which is why the existing number-only test passed and the bug went unnoticed.Reproduction
Fix
Route
PXATthroughtransformPXAT(milliseconds);EXATkeepstransformEXAT(seconds).transformPXATwas already imported. Numeric values are unchanged.Test
Added a
PXAT datecase toGETEX.spec.tsasserting the moderntype: 'PXAT'+Datepath encodesgetTime()(milliseconds). It fails before the change (seconds value) and passes after (milliseconds value).Note
Low Risk
Small, targeted fix in GETEX argument parsing with a regression test; no auth or broad API surface changes.
Overview
Fixes
GETEXwhen using{ type: 'PXAT', value: Date }: the command encoder no longer treats PXAT like EXAT. PXAT now goes throughtransformPXAT(millisecond absolute timestamps); EXAT still usestransformPXAT’s second-based siblingtransformEXAT.Previously both shared one branch that always applied second encoding, so a Date on the modern PXAT path was sent ~1000× too small and Redis could expire the key immediately. Numeric PXAT values were unaffected.
Adds a
GETEX.spec.tscase assertingtype: 'PXAT'+ Date serializesgetTime()as the argument.Reviewed by Cursor Bugbot for commit 69cc385. Bugbot is set up for automated code reviews on this repo. Configure here.