redis / redis/node-redis

Memory Leak when using brpop

Open
#1,511 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

I've this piece of code which is causing memory leaks.

var redis = require("redis");
var util = require("util");

client = redis.createClient();

var brpopAsync = util.promisify(client.brpop).bind(client);

setInterval(() => {
  process.nextTick( async () => {
   const data = await brpopAsync('testlist', 5);
 }) 
}, 200);

I inspected the code using chrome debugger and saw that this indeed is a closure leak. However, if I replace the brpop with rpop I don't get any memory leak. I'm trying to understand what's the issue with using brpop. How can brpop be used efficiently.


Environment
  • Node.js Version: v10.16.0
  • Redis Version: 4.0.9
  • Platform: Mac OSX, Amazon Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Node.js reproduction and compare the promisified brpop call with rpop under the same interval. Inspect the client's brpop handling and determine whether the reported closure and memory growth can be reproduced; done means explaining the cause and documenting an efficient usage pattern or a verified fix.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, redis
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.