redis/node-redis · error · TypeError
HOTKEYS GET: expected slot to be a finite number, got ${JSON
Error message
HOTKEYS GET: expected slot to be a finite number, got ${JSON.stringify(value)} What it means
Thrown by toSlotNumber while transforming a HOTKEYS GET reply, when an element that must be a Redis slot number (selected-slots ranges) cannot be coerced to a finite number via Number(). This is a reply-shape mismatch: the server returned something other than an integer where the client expects slot ordinals (0-16383).
Source
Thrown at packages/client/lib/commands/HOTKEYS_GET.ts:50
allCommandsAllSlotsUs: number;
/** Only present when sample-ratio > 1 AND selected-slots is not empty */
netBytesSampledCommandsSelectedSlots?: number;
/** Only present when selected-slots is not empty */
netBytesAllCommandsSelectedSlots?: number;
netBytesAllCommandsAllSlots: number;
collectionStartTimeUnixMs: number;
collectionDurationMs: number;
totalCpuTimeSysMs: number;
totalCpuTimeUserMs: number;
totalNetBytes: number;
byCpuTimeUs?: Array<HotkeyEntry>;
byNetBytes?: Array<HotkeyEntry>;
}
function toSlotNumber(value: unknown): number {
const slot = Number(value);
if (!Number.isFinite(slot)) {
throw new TypeError(
`HOTKEYS GET: expected slot to be a finite number, got ${JSON.stringify(value)}`
);
}
return slot;
}
/**
* Parse the hotkeys array into HotkeyEntry objects
*/
function parseHotkeysList(arr: unknown): Array<HotkeyEntry> {
return mapLikeEntries(arr).map(([key, value]) => ({
key,
value: Number(value)
}));
}
/**
* Parse slot ranges from the server response.View on GitHub (pinned to bb5beb5657)
Solutions
- Verify the Redis server version/build supports HOTKEYS GET in the reply shape the client expects.
- Upgrade @redis/client to a version matching your server's HOTKEYS implementation.
- If interoperating with a different schema, call sendCommand('HOTKEYS','GET') and parse the raw reply yourself instead of using the typed transform.
- Report the unexpected reply shape to node-redis with the server version and raw reply.
Example fix
// before: typed transform throws on a schema mismatch const data = await client.hotkeys.get(); // after: bypass the transform and inspect the raw reply to diagnose const raw = await client.sendCommand(['HOTKEYS', 'GET']); console.log(raw);
Defensive patterns
Strategy: try-catch
Validate before calling
// Server reply contents cannot be validated before the call. Diagnose via raw: // const raw = await client.sendCommand(['HOTKEYS','GET']);
Type guard
function isFiniteSlot(v) { return Number.isFinite(Number(v)); } Try / catch
try { return await client.hotkeys.get(); } catch (e) { if (/expected slot to be a finite number/.test(e.message)) { const raw = await client.sendCommand(['HOTKEYS','GET']); /* parse raw yourself */ } else throw e; } Prevention
- Match @redis/client version to the Redis server build that implements HOTKEYS.
- Use sendCommand for an untyped reply when server schema is in flux.
- Report schema mismatches with server version info.
When it happens
Trigger: Returned from client.hotkeys.get() when the server's HOTKEYS GET reply's selected-slots field contains a non-numeric value (string, null, NaN, undefined, nested object). Can indicate a server-side version that emits a different reply schema than the client's transformHotkeysGetReply expects.
Common situations: Redis server / module version mismatch where the HOTKEYS subcommand reply format changed; a proxy or RESP transformation layer mangling numeric fields into strings; pointing the client at a server build that does not implement HOTKEYS the way the client assumes.
AI-assisted analysis of redis/node-redis@bb5beb5657 (2026-08-03).
Data as JSON: /data/errors/bae7c1f5808de9b5.json.
Report an issue: GitHub.