Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
unpin opened this issue Apr 19, 2024 · 6 comments
Open

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

unpin opened this issue Apr 19, 2024 · 6 comments

Comments

@unpin
Copy link

unpin commented Apr 19, 2024

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
Copy link
Collaborator

lucsoft commented Apr 19, 2024

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

Do you have non base64 decodable chars in your string?

@unpin
Copy link
Author

unpin commented Apr 19, 2024

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
Copy link
Member

I think it's related to #406

@gustawdaniel
Copy link

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

@symful
Copy link

symful commented Feb 8, 2025

Is still happening on v0.34

@barefoot-alien
Copy link

Has anyone found a fix for this?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants