denodrivers / mongo

🍃 MongoDB driver for Deno 🦕
https://deno.land/x/mongo
MIT License
514 stars 95 forks source link

Error: MongoError: "Connection failed: Failed to decode base64" #411

Open unpin opened 7 months ago

unpin commented 7 months ago

After upgrading to mongo@v0.33.0, the connection consistently fails with the error "Connection failed: Failed to decode base64", occurring both locally and on Deno Deploy. I had to downgrade to mongo@v0.32.0 for now.

import { Database, MongoClient } from "mongo";

const DATABASE_URL = "mongodb+srv://<username>:<password>@<db_cluster_url>/<db_name>?authMechanism=SCRAM-SHA-1"

const client = new MongoClient();
await client.connect(DATABASE_URL);
lucsoft commented 7 months ago

Can you give more backstory? what db cluster is this? Atlas?

Do you have non base64 decodable chars in your string?

unpin commented 7 months ago

Sure! I'm trying to connect to a free tier Atlas cluster and this is what my connection string basically looks like:

const DATABASE_URL = "mongodb+srv://admin:123456@cluster/db?authMechanism=SCRAM-SHA-1"

Username and password contain only Base64 chars. Connection establishes without any problems when using mongo@v0.32.0 or earlier, but fails when using mongo@v0.33.0.

erfanium commented 7 months ago

I think it's related to #406

gustawdaniel commented 1 week ago

I have this for 0.33

AError connecting to MongoDB Error: MongoError: "Connection failed: Failed to decode base64"
    at MongoClient.connect (https://deno.land/x/mongo@v0.33.0/src/client.ts:63:13)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async getDb (file:///home/daniel/pro/matrix-aggregator-scraper/src/storage/mongo.ts:17:5)
    at async file:///home/daniel/pro/matrix-aggregator-scraper/db.ts:4:14
error: Uncaught (in promise) Error: MongoError: "Connection failed: Failed to decode base64"
      throw new MongoDriverError(`Connection failed: ${e.message || e}`);
            ^
    at MongoClient.connect (https://deno.land/x/mongo@v0.33.0/src/client.ts:63:13)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async getDb (file:///home/daniel/pro/matrix-aggregator-scraper/src/storage/mongo.ts:17:5)
    at async file:///home/daniel/pro/matrix-aggregator-scraper/db.ts:4:14