Skip to content

getting random buffer responses #2979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
punkpeye opened this issue May 27, 2025 · 1 comment
Open

getting random buffer responses #2979

punkpeye opened this issue May 27, 2025 · 1 comment
Assignees
Labels

Comments

@punkpeye
Copy link

punkpeye commented May 27, 2025

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
@punkpeye punkpeye added the Bug label May 27, 2025
@nkaradzhov
Copy link
Collaborator

@punkpeye thanks, i will have a look

@nkaradzhov nkaradzhov self-assigned this May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants