Skip to content

Commit a319430

Browse files
authored
chore(cli-repl): log env vars useful for troubleshooting MONGOSH-1064 (#1161)
Log the values of: - `$TERM`, because knowing the terminal type can be useful for debugging issues regarding our usage of the Node.js readline module - `$EDITOR`, because it is used by the `edit` feature - `$NODE_OPTIONS`, because it influences the way that mongosh runs (and in particular can contain preload modules)
1 parent a2e4a98 commit a319430

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/cli-repl/src/cli-repl.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { bson, AutoEncryptionOptions } from '@mongosh/service-provider-core';
55
import { CliOptions, CliServiceProvider, MongoClientOptions } from '@mongosh/service-provider-server';
66
import { SnippetManager } from '@mongosh/snippet-manager';
77
import { Editor } from '@mongosh/editor';
8+
import { redactSensitiveData } from '@mongosh/history';
89
import Analytics from 'analytics-node';
910
import askpassword from 'askpassword';
1011
import ConnectionString from 'mongodb-connection-string-url';
@@ -181,6 +182,7 @@ class CliRepl {
181182

182183
logger.info('MONGOSH', mongoLogId(1_000_000_000), 'log', 'Starting log', {
183184
execPath: process.execPath,
185+
envInfo: redactSensitiveData(this.getLoggedEnvironmentVariables()),
184186
...buildInfo()
185187
});
186188

@@ -571,6 +573,12 @@ class CliRepl {
571573
bugReportErrorMessageInfo(): string {
572574
return `Please include the log file for this session (${this.logWriter?.logFilePath}).`;
573575
}
576+
577+
/** Return environment variables that can be useful for troubleshooting */
578+
getLoggedEnvironmentVariables(): Record<string, string | undefined> {
579+
const { EDITOR, NODE_OPTIONS, TERM } = process.env;
580+
return { EDITOR, NODE_OPTIONS, TERM };
581+
}
574582
}
575583

576584
export default CliRepl;

0 commit comments

Comments
 (0)