Skip to content

Commit 4341cdb

Browse files
authored
chore(compass): work around local dev issue with loading worker from a file COMPASS-8504 (#6494)
chore(compass): work around local dev issue with loading worker from a file
1 parent 03e8694 commit 4341cdb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/compass/src/setup-hadron-distribution.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from 'path';
2-
import { app } from 'electron';
2+
import { app, protocol, net } from 'electron';
33

44
/**
55
* All these variables below are used by Compass and its plugins in one way or
@@ -54,6 +54,16 @@ if (
5454
// seemingly nothing is using this path anyway, we probably can ignore an
5555
// error here
5656
app.setPath('userCache', path.join(app.getPath('cache'), app.getName()));
57+
58+
// TODO(COMPASS-8269): even with `webSecurity` disabled for local dev,
59+
// file:// requests for shell worker are silently getting canceled by the
60+
// browser, adding explicit protocol handler for it that just does the same
61+
// request using electron network stack works around the issue
62+
void app.whenReady().then(() => {
63+
protocol.handle('file', (req) => {
64+
return net.fetch(req, { bypassCustomProtocolHandlers: true });
65+
});
66+
});
5767
}
5868

5969
app.setPath(

0 commit comments

Comments
 (0)