bullmq: [Bug]: split redis version error

Version

v5.47.3

Platform

NodeJS

What happened?

private async getRedisVersion() {
    const doc = await this._client.info();
    const redisPrefix = 'redis_version:';
    const maxMemoryPolicyPrefix = 'maxmemory_policy:';
    const lines = doc.split('\r\n');
    let redisVersion;

    for (let i = 0; i < lines.length; i++) {
      if (lines[i].indexOf(maxMemoryPolicyPrefix) === 0) {
        const maxMemoryPolicy = lines[i].substr(maxMemoryPolicyPrefix.length);
        if (maxMemoryPolicy !== 'noeviction') {
          console.warn(
            `IMPORTANT! Eviction policy is ${maxMemoryPolicy}. It should be "noeviction"`,
          );
        }
      }

      if (lines[i].indexOf(redisPrefix) === 0) {
        redisVersion = lines[i].substr(redisPrefix.length);
      }
    }

    return redisVersion;
  }

The obtained doc is not correctly segmented by \r\n, resulting in the inability to obtain the corresponding version information.

to fix

const lines = doc.split(/\r?\n/);

How to reproduce.

No response

Relevant log output

TypeError: Invalid version. Must be a string. Got type "object".
    at new SemVer (/Users/yasuo/Desktop/workspace/jojo/qa-workbench-service/node_modules/.pnpm/semver@7.7.1/node_modules/semver/classes/semver.js:20:13)
    at compare (/Users/yasuo/Desktop/workspace/jojo/qa-workbench-service/node_modules/.pnpm/semver@7.7.1/node_modules/semver/functions/compare.js:3:3)
    at Object.lt (/Users/yasuo/Desktop/workspace/jojo/qa-workbench-service/node_modules/.pnpm/semver@7.7.1/node_modules/semver/functions/lt.js:2:29)
    at isRedisVersionLowerThan (/Users/yasuo/Desktop/workspace/jojo/qa-workbench-service/node_modules/.pnpm/bullmq@5.46.1/node_modules/bullmq/src/utils.ts:228:17)
    at RedisConnection.init (/Users/yasuo/Desktop/workspace/jojo/qa-workbench-service/node_modules/.pnpm/bullmq@5.46.1/node_modules/bullmq/src/classes/redis-connection.ts:256:34)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @roggervalf Sorry for the confusion. I am actually referring to this issue! (Which already exists.)

Can you take a look at @XianZhengquan’s PR #3208?

I tried to modify the local code and it worked for me