Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Connection failed: Failed to decode base64 #381

Open
demienYu opened this issue Oct 23, 2022 · 2 comments
Open

Connection failed: Failed to decode base64 #381

demienYu opened this issue Oct 23, 2022 · 2 comments

Comments

@demienYu
Copy link

From time 2 time i see this error.
Call stack:
Error: MongoError: "Connection failed: Failed to decode base64."
at MongoClient.connect (https://deno.land/x/[email protected]/src/client.ts:46:13)

my code looks like this:

export { MongoClient } from "https://deno.land/x/[email protected]/mod.ts"
const client = new MongoClient()
const options = {
servers: [{host: MONGO_HOST, port: MONGO_PORT}],
credential: {username: MONGO_USER, password: MONGO_PWD, db: 'admin', mechanism: 'SCRAM-SHA-1'},
db: 'mydb'
}
await client.connect(options) // this line causes error

@markwylde
Copy link

markwylde commented Dec 4, 2023

I'm getting this too periodically. I wonder if it's anything to do with this:
denoland/deno#19546

The full error I get is:

error: InvalidCharacterError: Failed to decode base64
  const binString = atob(b64);
                    ^
    at atob (ext:deno_web/05_base64.js:28:16)
    at Module.decode (https://deno.land/[email protected]/encoding/base64.ts:138:21)
    at continueScramConversation (file:///testproject/mongo/src/auth/scram.ts:196:11)
    at eventLoopTick (ext:core/01_core.js:178:11)
    at async Cluster.authenticateToServer (file:///testproject/mongo/src/cluster.ts:86:7)
    at async Promise.all (index 0)
    at async Cluster.authenticate (file:///testproject/mongo/src/cluster.ts:55:23)
    at async MongoClient.connect (file:///testproject/mongo/src/client.ts:37:7)
    at async createDatabase (file:///testproject/lib/utils/createDatabase.ts:25:3)

@markwylde
Copy link

I've tried using a custom base64 locally and it seems to have solved the issues for me:
#406

Obviously not a long term solution, but maybe it will work until the deno issue is resolved.

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

No branches or pull requests

2 participants