Error using Mongo shell in mongo compass app

Hello everyone, we are encountering this issue after running even simple query (db.coll.findOne({}) in mongo shell inside mongo compass. Has anyone encountered similar problem? Are there any suggestions to solve it?

ReferenceError: app is not defined
  if (_fs === "returned") return _srv;else if (_fs === "threw") throw _srv;
                                                                ^

ReferenceError: app is not defined
    at evalmachine.<anonymous>:36:162
    at evalmachine.<anonymous>:208:5
    at evalmachine.<anonymous>:213:3
    at Script.runInContext (node:vm:139:12)
    at Object.runInContext (node:vm:289:6)
    at ElectronInterpreterEnvironment.sloppyEval (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:2160437)
    at ShellEvaluator.innerEval (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:3905059)
    at ShellEvaluator.customEval (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:3905203)
    at OpenContextRuntime.evaluate (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:2159555)
    at ElectronRuntime.evaluate (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:2160971)

Current mongo compass version: 1.35.0
Operation system: MacOS

@Wiktor_Janiszewski would you be able to share a log file?

This is log after putting findOne command:

{"t":{"$date":"2023-02-06T12:07:24.938Z"},"s":"I","c":"MONGOSH","id":1000000007,"ctx":"repl","msg":"Evaluating input","attr":{"input":"db.cross-app-test.findOne({})"}}
{"t":{"$date":"2023-02-06T12:07:24.956Z"},"s":"I","c":"MONGOSH","id":1000000007,"ctx":"repl","msg":"Evaluating input","attr":{"input":"(() => {\n        switch (typeof prompt) {\n          case 'function':\n            return prompt();\n          case 'string':\n            return prompt;\n        }\n      })()"}}
{"t":{"$date":"2023-02-06T12:07:28.483Z"},"s":"I","c":"COMPASS-AUTO-UPDATES","id":1001000135,"ctx":"AutoUpdateManager","msg":"Checking for updates ..."}
{"t":{"$date":"2023-02-06T12:07:30.190Z"},"s":"I","c":"COMPASS-AUTO-UPDATES","id":1001000126,"ctx":"AutoUpdateManager","msg":"Update not available"}

I’d like to inform you that I connected to the same instance as previously but using pymongo and then I could run the queries without problem, I didn’t receive that was mentioned above.

@Wiktor_Janiszewski The MongoDB shell is a JavaScript environment and will evaluate its input as JavaScript before running it. This means that

db.cross-app-test.findOne({})

is interpreted as

db.cross - app - test.findOne({})

with the - signs standing for literal subtraction operations.

You can work around this by using either of the following:

db['cross-app-test'].findOne({})
db.getCollection('cross-app-test').findOne({})

This is an inherent limitation when using hyphen characters in collection names.

3 Likes

Thanks for reply, I don’t believe it was caused by this. We’ve managed to figure it out. We overcame this issue by updating Atlas plan from M0 to M10.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.