Skip to content

Commit ccfba41

Browse files
authored
fix(compass): only access defaultSession when app is ready (#5542)
1 parent b239503 commit ccfba41

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/compass/src/main/application.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class CompassApplication {
113113
return;
114114
}
115115

116-
this.setupCORSBypass();
116+
await this.setupCORSBypass();
117117
void this.setupCompassAuthService();
118118
this.setupAutoUpdate();
119119
await setupCSFLELibrary();
@@ -306,7 +306,7 @@ class CompassApplication {
306306
return this;
307307
}
308308

309-
private static setupCORSBypass() {
309+
private static async setupCORSBypass() {
310310
const CLOUD_URLS_FILTER = {
311311
urls: [
312312
'*://cloud.mongodb.com/*',
@@ -340,6 +340,9 @@ class CompassApplication {
340340
'access-control-max-age',
341341
];
342342

343+
// Accessing defaultSession is not allowed when app is not ready
344+
await app.whenReady();
345+
343346
session.defaultSession.webRequest.onBeforeSendHeaders(
344347
CLOUD_URLS_FILTER,
345348
(details, callback) => {

0 commit comments

Comments
 (0)