After having moved from the old mongo commandline to mongosh, I am struggling with the lack of info from debug output when scripts run into problems. For comparison with the old (i.e. 3.6ish) behaviour, consider the two following JS files:
foo.js:
print('Hello');
load('./bar.js');
bar.js:
print(' World');
noSuchFunction();
Running this on the legacy mongo 3.6 instance, I get some helpful info:
~ /usr/bin/mongo --quiet foo ./foo.js
Hello
World
2023-09-21T09:56:49.765+0200 E QUERY [thread1] [./bar.js:2:1] ReferenceError: noSuchFunction is not defined
Stack trace:
@./bar.js:2:1
@./foo.js:2:1
----------
2023-09-21T09:56:49.765+0200 E QUERY [thread1] Error: error loading js file: ./bar.js @./foo.js:2:1
failed to load: ./foo.js
In mongosh (1.10.1, running on MongoDB 6.0.8), debug output is somewhat on the meagre side:
~ /usr/bin/mongosh --quiet foo ./foo.js
Hello
World
ReferenceError: noSuchFunction is not defined
I have scanned the documentation, but I didn’t find anything referencing mongosh debug output. The --verbose
-Flag doesn’t help either. Once you have to deal with some more complex scripts running generated aggregations, this is becoming a major pain. I am fairly certain that I’ve just overlooked something in the configuration, but I cannot for the life of me figure out what it could be.
Is there any way to get the old behaviour back with mongosh, so a stack trace with filenames and line numbers is shown for errors? I already tried with /etc/mongosh.conf
- this currently reads
mongosh:
showStackTraces: true
If I add some error to /etc/mongosh.conf
, mongosh complains, so I am fairly sure that this config is actually read. Still, no stack traces for me.
Kind regards
Markus