Skip to content

Commit

Permalink
more granular and don't do anything before the app is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
lerouxb committed Dec 27, 2024
1 parent 9401c55 commit ba4f8b3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/compass/src/main/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class CompassApplication {
safeStorage.setUsePlainTextEncryption(true);
}

process.stdout.write('before first app.whenReady\n');
await app.whenReady();
process.stdout.write('after first app.whenReady\n');

process.stdout.write('before setupPreferencesAndUser\n');
const { preferences } = await setupPreferencesAndUser(
globalPreferences,
Expand Down Expand Up @@ -194,7 +198,12 @@ class CompassApplication {
}

private static async setupCompassAuthService() {
await CompassAuthService.init(this.preferences, this.httpClient);
try {
await CompassAuthService.init(this.preferences, this.httpClient);
} catch (err: any) {
process.stdout.write('Got CompassAuthService.init error\n');
throw err;
}
this.addExitHandler(() => {
return CompassAuthService.onExit();
});
Expand Down Expand Up @@ -310,14 +319,18 @@ class CompassApplication {
logContext: string
): Promise<() => void> {
const onChange = async (value: string) => {
process.stdout.write('setupProxySupport onChange\n');
try {
const proxyOptions = proxyPreferenceToProxyOptions(value);
await app.whenReady();

process.stdout.write('after setupProxySupport app.whenReady\n');

try {
const electronProxyConfig =
translateToElectronProxyConfig(proxyOptions);
await target.setProxy(electronProxyConfig);
process.stdout.write('after setupProxySupport target.setProxy\n');
} catch (err) {
const headline = String(
err && typeof err === 'object' && 'message' in err
Expand All @@ -335,6 +348,7 @@ class CompassApplication {
}
);
await target.setProxy({});
process.stdout.write('after setupProxySupport target.setProxy({})\n');
}

const agent = createAgent(proxyOptions);
Expand All @@ -361,6 +375,9 @@ class CompassApplication {
),
}
);
process.stdout.write(
'after setupProxySupport Unable to set proxy configuration\n'
);
}
};
const unsubscribe = this.preferences.onPreferenceValueChanged(
Expand Down

0 comments on commit ba4f8b3

Please sign in to comment.