Skip to content

getting random buffer responses #2979

Open
@punkpeye

Description

@punkpeye

Description

await redis.set(KEY, STRING_VALUE, {
  expiration: {
    type: 'PX',
    value: 1000,
  },
});

let cached = await redis.get(KEY);

Here I would expect await redis.get(KEY) to always return a string, but I am seeing it return at random either a string or a buffer.

When I say at random, I mean that I didn't identify what causes it sometimes to return one or the other, but it seems like once it starts to return a buffer for a key it always does.

I worked around this issue with:

if (Buffer.isBuffer(cached)) {
  try {
    cached = Buffer.from(cached).toString('utf8');
  } catch (error) {
    console.error('could not convert buffer to string', {
      error,
      extra: {
        KEY,
      },
    });
  }
}

but regardless this feels like a bug.

Node.js Version

v24.0.1

Redis Server Version

8

Node Redis Version

5.1.0

Platform

Linux

Logs

n/a

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions