Skip to content

hScanValuesIterator yields field names instead of values #3343

Closed

Description

@winklemad

RedisClient.hScanValuesIterator() is meant to stream a hash's values — the values-only counterpart to hScanIterator (which yields { field, value } entries) and hScanNoValuesIterator (which yields field names).

However, its body is a copy of hScanNoValuesIterator: it calls hScanNoValues() — which issues HSCAN ... NOVALUES, a reply that by protocol contains only field names — and then yields reply.fields. As a result it returns hash field names, byte-for-byte identical to hScanNoValuesIterator, and can never return values.

https://github.com/redis/node-redis/blob/master/packages/client/lib/client/index.ts#L1690-L1701

Reproduction

For a hash { f1: 'v1', f2: 'v2' }:

for await (const values of client.hScanValuesIterator('myhash')) {
  console.log(values);
}
// observed: [ 'f1', 'f2' ]   (field names)
// expected: [ 'v1', 'v2' ]   (values)

Fix

Iterate the full HSCAN (as hScanIterator already does) and yield the values:

async *hScanValuesIterator(this, key, options) {
  let cursor = options?.cursor ?? '0';
  do {
    const reply = await this.hScan(key, cursor, options);
    cursor = reply.cursor;
    yield reply.entries.map(entry => entry.value);
  } while (cursor !== '0');
}

I'll open a PR with this fix.

Activity

  1. nkaradzhov commented on Jul 21, 2026

    @nkaradzhov
    Collaborator

    Addressed in #3344

  2. added a commit that references this issue on Jul 21, 2026
    a895dcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions