Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #2120
Closed
Open
Issue created Jul 30, 2021 by Administrator@rootContributor

Queue is missing redis username support from url

Created by: StefanCenusa

Description

Queue doesn't parse the username out of the redis url. Of course, username could be passed with redis options, but I think it would be nice to parse/get all the information from the url string if possible.

function redisOptsFromUrl(urlString) {
  const redisOpts = {};
  try {
    const redisUrl = url.parse(urlString);
    redisOpts.port = redisUrl.port || 6379;
    redisOpts.host = redisUrl.hostname;
    redisOpts.db = redisUrl.pathname ? redisUrl.pathname.split('/')[1] : 0;
    if (redisUrl.auth) {
      redisOpts.password = redisUrl.auth.split(':')[1];
    }
  } catch (e) {
    throw new Error(e.message);
  }
  return redisOpts;
}

https://github.com/OptimalBits/bull/blob/develop/lib/queue.js#L305

A simple solution would be:

if (redisUrl.auth) {
    const columnIndex = redisUrl.auth.indexOf(':');
    redisOpts.password = redisUrl.auth.slice(columnIndex + 1);
    if (columnIndex > 0) {
        redisOpts.user = redisUrl.auth.slice(0, columnIndex);
    }
}

Should I open a PR for this change?

Bull version

3.27.0

Assignee
Assign to
Time tracking