Skip to content

[CouchDB] Name or password is incorrect. #227

@zmaximo1990

Description

@zmaximo1990

Describe the bug
After upgrade to the version 1.4.18 my connection to couchdb is broken.

To Reproduce
Steps to reproduce the behavior:

Run this script:

const ueberdb = require("ueberdb2");

const db = new ueberdb.Database("couch", {
  user: "username",
  password: "pass",
  host: "localhost",
  port: 5984,
  database: "dbname",
});

async function example(db) {
  await db.init();

  // no need for await because it's already in cache.
  db.set("valueA", { a: 1, b: 2 });

  db.get("valueA", function (err, value) {
    console.log("VALUE", value);
    // close the database connection.
    db.close(function () {
      process.exit(0);
    });
  });
}

example(db);

OUTPUT:
Captura de Pantalla 2022-04-01 a la(s) 14 10 15

(node:86719) UnhandledPromiseRejectionWarning: Error: Name or password is incorrect.
    at responseHandler (/Users/max/Desktop/test-db/node_modules/nano/lib/nano.js:188:20)
    at /Users/max/Desktop/test-db/node_modules/nano/lib/nano.js:420:11
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:86719) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:86719) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After inspecting databases/couch_db.js file, the config.auth values are incorrect.

Current values:

const config = {
      url: `http://${settings.host}:${settings.port}`,
      requestDefaults: {
        pool: {
          maxSockets: settings.maxListeners || 1,
        },
        auth: {
          user: settings.user,
          pass: settings.password,
        },
      },
    };

After change auth properties from user and pass to username and password the connection was successfully.

const config = {
      url: `http://${settings.host}:${settings.port}`,
      requestDefaults: {
        pool: {
          maxSockets: settings.maxListeners || 1,
        },
        auth: {
          username: settings.user,
          password: settings.password,
        },
      },
    };

Captura de Pantalla 2022-04-01 a la(s) 14 14 25

PLEASE 🙏🏻 could you check that? Or what am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions