@@ -2,6 +2,7 @@ import './disable-node-deprecations'; // Separate module so it runs first
22import path from 'path' ;
33import { EventEmitter } from 'events' ;
44import type { BrowserWindow , Event , ProxyConfig } from 'electron' ;
5+ import { dialog } from 'electron' ;
56import { app , safeStorage , session } from 'electron' ;
67import { ipcMain } from 'hadron-ipc' ;
78import type { AutoUpdateManagerState } from './auto-update-manager' ;
@@ -301,7 +302,41 @@ class CompassApplication {
301302 try {
302303 const proxyOptions = proxyPreferenceToProxyOptions ( value ) ;
303304 await app . whenReady ( ) ;
304- await target . setProxy ( translateToElectronProxyConfig ( proxyOptions ) ) ;
305+
306+ try {
307+ const electronProxyConfig =
308+ translateToElectronProxyConfig ( proxyOptions ) ;
309+ await target . setProxy ( electronProxyConfig ) ;
310+ } catch ( err ) {
311+ const headline = String (
312+ err && typeof err === 'object' && 'message' in err
313+ ? err . message
314+ : err ||
315+ 'Currently Compass does not support authenticated or ssh proxies.'
316+ ) ;
317+
318+ log . warn (
319+ mongoLogId ( 1_001_000_332 ) ,
320+ logContext ,
321+ 'Unable to set proxy configuration' ,
322+ {
323+ error : headline ,
324+ }
325+ ) ;
326+
327+ const sep = path . sep ;
328+ const configPath = `${ app . getPath (
329+ 'userData'
330+ ) } ${ sep } AppPreferences${ sep } General.json`;
331+
332+ dialog . showErrorBox (
333+ 'Unsupported proxy configuration' ,
334+ `${ headline } \n\n
335+ To reset the proxy configuration, remove the "proxy" key in ${ configPath } and restart Compass.`
336+ ) ;
337+
338+ app . quit ( ) ;
339+ }
305340
306341 const agent = createAgent ( proxyOptions ) ;
307342 const fetch = createFetch ( agent || { } ) ;
0 commit comments