Skip to content

Commit eecf588

Browse files
committed
fix(compass): disable spellcheck before creating window when no network traffic COMPASS-8166
1 parent 3a70049 commit eecf588

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

packages/compass/src/main/application.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ class CompassApplication {
129129
// Accessing isEncryptionAvailable is not allowed when app is not ready on Windows
130130
// https://github.com/electron/electron/issues/33640
131131
await app.whenReady();
132+
133+
const { networkTraffic } = this.preferences.getPreferences();
134+
135+
if (!networkTraffic) {
136+
// Electron fetches spellcheck dictionaries from a CDN
137+
// on all OSs expect mac (it provides a built-in spell check).
138+
// Passing a non-resolving URL prevents it from fetching
139+
// as there aren't any options to disable it provided.
140+
// https://github.com/electron/electron/issues/22995
141+
session.defaultSession.setSpellCheckerDictionaryDownloadURL(
142+
'http://127.0.0.1:0/'
143+
);
144+
}
145+
132146
log.info(
133147
mongoLogId(1_001_000_307),
134148
'Application',

packages/compass/src/main/window-manager.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,13 @@ function showConnectWindow(
140140
};
141141

142142
debug('creating new main window:', windowOpts);
143-
const { preferences } = compassApp;
144-
const { networkTraffic } = preferences.getPreferences();
145-
146143
let window: BrowserWindow | null = new BrowserWindow(windowOpts);
147144
if (mongodbUrl) {
148145
registerMongoDbUrlForBrowserWindow(window, mongodbUrl);
149146
}
150147
if (connectionId) {
151148
registerConnectionIdForBrowserWindow(window, connectionId);
152149
}
153-
if (networkTraffic !== true) {
154-
// https://github.com/electron/electron/issues/22995
155-
window.webContents.session.setSpellCheckerDictionaryDownloadURL(
156-
'http://127.0.0.1:0/'
157-
);
158-
}
159150

160151
enable(window.webContents);
161152
const unsubscribeProxyListenerPromise = compassApp.setupProxySupport(

0 commit comments

Comments
 (0)