Skip to content

Commit 8c64dee

Browse files
authored
chore: add some logs for clarification when there are parse errors in the CLI (#5328)
* Add some logs for clarification when there are parse errors in the CLI * more logging * only log the --ignore-additional-command-line-flags thing if necessary * disable the GPU in e2e tests * specify generic desktop environment * seems like the form field does not immediately update * print cli errors when caught * remove logging that seems to fool mocha * test * Revert "test" This reverts commit a8907d3. * shorten the timeout again
1 parent 1df00d7 commit 8c64dee

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

packages/compass-e2e-tests/helpers/chrome-startup-flags.ts

+3
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ const CI_FLAGS = [
5151
// Evergren RHEL ci runs everything as root, and chrome will not start as
5252
// root without this flag
5353
'--no-sandbox',
54+
// Seeing gpu init related errors on at least RHEL, especially when starting
55+
// the CLI
56+
'--disable-gpu',
5457
];
5558

5659
// These flags are used to start Chrome driver based on the Compass requirements.

packages/compass-e2e-tests/helpers/compass.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,13 @@ export async function runCompassOnce(args: string[], timeout = 30_000) {
448448
`--user-data-dir=${String(defaultUserDataDir)}`,
449449
...args,
450450
],
451-
{ timeout }
451+
{
452+
timeout,
453+
env: {
454+
...process.env,
455+
DE: 'generic', // for xdg-settings: unknown desktop environment
456+
},
457+
}
452458
);
453459
debug('Ran compass with args', { args, stdout, stderr });
454460
return { stdout, stderr };

packages/compass-e2e-tests/tests/import-export-connections.test.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,14 @@ describe('Connection Import / Export', function () {
7979
await browser.selectFavorite(favoriteName);
8080
await browser.clickVisible(Selectors.EditConnectionStringToggle);
8181
await browser.clickVisible(Selectors.ConfirmationModalConfirmButton());
82-
expect(await browser.getConnectFormConnectionString(true)).to.equal(
83-
variant === 'protected'
84-
? connectionStringWithoutCredentials
85-
: connectionString
86-
);
82+
await browser.waitUntil(async () => {
83+
const cs = await browser.getConnectFormConnectionString(true);
84+
const expected =
85+
variant === 'protected'
86+
? connectionStringWithoutCredentials
87+
: connectionString;
88+
return cs === expected;
89+
});
8790
await browser.selectFavorite(favoriteName);
8891
await browser.selectConnectionMenuItem(
8992
favoriteName,
@@ -203,7 +206,7 @@ describe('Connection Import / Export', function () {
203206
// it takes to save a favorite in e2e tests, and so the result of that
204207
// initial load would override the favorite saving (from the point of view
205208
// of the connection sidebar at least). Add a timeout to make this less flaky. :(
206-
await new Promise((resolve) => setTimeout(resolve, 2000));
209+
await new Promise((resolve) => setTimeout(resolve, 5000));
207210

208211
await browser.saveFavorite(favoriteName, 'color3');
209212
});

packages/compass/src/main/index.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ async function main(): Promise<void> {
6565
return app.exit(0);
6666
}
6767

68-
if (preferenceParseErrors.length > 0) {
68+
const errorOutDueToAdditionalCommandLineFlags =
69+
preferenceParseErrors.length > 0 &&
70+
!preferences.ignoreAdditionalCommandLineFlags;
71+
72+
if (errorOutDueToAdditionalCommandLineFlags) {
6973
process.stderr.write(chalk.yellow(preferenceParseErrorsString) + '\n');
7074
process.stderr.write(
7175
'Use --ignore-additional-command-line-flags to allow passing additional options to Chromium/Electron\n'
7276
);
7377
}
74-
const errorOutDueToAdditionalCommandLineFlags =
75-
preferenceParseErrors.length > 0 &&
76-
!preferences.ignoreAdditionalCommandLineFlags;
7778

7879
const importExportOptions = {
7980
exportConnections: preferences.exportConnections,
@@ -101,9 +102,19 @@ async function main(): Promise<void> {
101102
process.on('uncaughtException', handleUncaughtException);
102103
} else {
103104
if (errorOutDueToAdditionalCommandLineFlags) {
105+
process.stderr.write(
106+
'Exiting because there are parse errors and --ignore-additional-command-line-flags was not set\n'
107+
);
104108
return app.exit(1);
105109
}
106110
process.on('uncaughtException', (err) => {
111+
process.stderr.write('Exiting due to uncaughtException:\n');
112+
// eslint-disable-next-line no-console
113+
console.error(err);
114+
CompassApplication.runExitHandlers().finally(() => app.exit(1));
115+
});
116+
process.on('unhandledRejection', (err) => {
117+
process.stderr.write('Exiting due to unhandledRejection:\n');
107118
// eslint-disable-next-line no-console
108119
console.error(err);
109120
CompassApplication.runExitHandlers().finally(() => app.exit(1));
@@ -113,7 +124,13 @@ async function main(): Promise<void> {
113124
try {
114125
await CompassApplication.init(mode, globalPreferences);
115126
} catch (e) {
116-
await handleUncaughtException(e as Error);
127+
if (mode === 'CLI') {
128+
process.stderr.write('Exiting due to try/catch:\n');
129+
// eslint-disable-next-line no-console
130+
console.error(e);
131+
} else {
132+
await handleUncaughtException(e as Error);
133+
}
117134
await CompassApplication.runExitHandlers().finally(() => app.exit(1));
118135
return;
119136
}

0 commit comments

Comments
 (0)