From 4341cdbc773a58bcc02e2c3e79487b85acd7de82 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Thu, 14 Nov 2024 17:16:43 +0100 Subject: [PATCH] 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 --- packages/compass/src/setup-hadron-distribution.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/compass/src/setup-hadron-distribution.ts b/packages/compass/src/setup-hadron-distribution.ts index 534a402175f..ea8ba62212a 100644 --- a/packages/compass/src/setup-hadron-distribution.ts +++ b/packages/compass/src/setup-hadron-distribution.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { app } from 'electron'; +import { app, protocol, net } from 'electron'; /** * All these variables below are used by Compass and its plugins in one way or @@ -54,6 +54,16 @@ if ( // seemingly nothing is using this path anyway, we probably can ignore an // error here app.setPath('userCache', path.join(app.getPath('cache'), app.getName())); + + // TODO(COMPASS-8269): even with `webSecurity` disabled for local dev, + // file:// requests for shell worker are silently getting canceled by the + // browser, adding explicit protocol handler for it that just does the same + // request using electron network stack works around the issue + void app.whenReady().then(() => { + protocol.handle('file', (req) => { + return net.fetch(req, { bypassCustomProtocolHandlers: true }); + }); + }); } app.setPath(