Does JS Driver Support `appName` in Connection String?

The JS code:

const url = process.env.MONGO_URL;
const mongoClient = await MongoClient.connect(url);

The .env file:


These codes cause the following error:

MongoServerSelectionError: failed to handle command request "ismaster": error processing client metadata: expected app name to be composed of: <appID>:<svc>:<authProvider>, got [object Object]

I think the error shows something wrong with the appName parameter.

I first thought it was a Realm problem, but the connection string properly works in CLI (i.e. the mongo command), so I’m now thinking this is related to JS Driver. (FYI: I’m using ver 3.6.2)

Is this an expected behavior or a bug?

Hi @Toshi,

The Node JS driver with latest versions should work with Realm wire protocols:

Do you see any server side logging for this attempts?


1 Like

Hi Pavel, thanks for the response. Firstly, I can’t find any logs recorded in the Realm UI unfortunately.

Actually, you can reproduce the problem in a couple of minutes:

# in empty directory
npm init -y
npm install mongodb
touch index.js


const MongoClient = require('mongodb');

const main = async () => {
  await MongoClient.connect(MONGO_URL);

main().catch(err => {

If you use a normal Atlas url, it works properly. (i.e. mongodb+srv://<username>:<password>

On the other hand, if you use a Realm url, you’ll see the
expected <appID>:<svc>:<authProvider>, got [object Object]” error.

I’d appreciate it if you could check.

I tried several more attempts with some guesswork (still not working).
I guess there is possibly something wrong with dealing with colons.

1. Using the string copied form Realm UI (“Data Source” page)

The connection string which has


will produce this error:
expected ... <appID>:<svc>:<authProvider>, got [object Object]

2. Using URL encoded one (colon → %3A)


will produce the same error:
expected ... <appID>:<svc>:<authProvider>, got [object Object]

3. Using a plain string without colons


This time the param was not converted to an [object Object].
The error message says it got the string instead:
expected ... <appID>:<svc>:<authProvider>, got application-0-xxxxx

Again, the connection string correctly worked with CLI (the mongo command). It seems it is not working only with Node.js SDK.