Skip to content

fix(compass): disable spellcheck before creating window when no network traffic COMPASS-8166 #6837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/compass/src/main/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ class CompassApplication {
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
// https://github.com/electron/electron/issues/33640
await app.whenReady();

const { networkTraffic } = this.preferences.getPreferences();

if (!networkTraffic) {
// Electron fetches spellcheck dictionaries from a CDN
// on all OSs expect mac (it provides a built-in spell check).
// Passing a non-resolving URL prevents it from fetching
// as there aren't any options to disable it provided.
// https://github.com/electron/electron/issues/22995
session.defaultSession.setSpellCheckerDictionaryDownloadURL(
'http://127.0.0.1:0/'
);
}

log.info(
mongoLogId(1_001_000_307),
'Application',
Expand Down
8 changes: 0 additions & 8 deletions packages/compass/src/main/window-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ function showConnectWindow(
};

debug('creating new main window:', windowOpts);
const { preferences } = compassApp;
const { networkTraffic } = preferences.getPreferences();

let window: BrowserWindow | null = new BrowserWindow(windowOpts);
if (mongodbUrl) {
Expand All @@ -150,12 +148,6 @@ function showConnectWindow(
if (connectionId) {
registerConnectionIdForBrowserWindow(window, connectionId);
}
if (networkTraffic !== true) {
// https://github.com/electron/electron/issues/22995
window.webContents.session.setSpellCheckerDictionaryDownloadURL(
'http://127.0.0.1:0/'
);
}

enable(window.webContents);
const unsubscribeProxyListenerPromise = compassApp.setupProxySupport(
Expand Down
Loading