denodrivers / mongo

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

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

Open unpin opened 6 months ago

unpin commented 6 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 6 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 6 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 6 months ago

I think it's related to #406