diff --git a/src/common/register-protocol.ts b/src/common/register-protocol.ts deleted file mode 100644 index db00778b2e..0000000000 --- a/src/common/register-protocol.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ - -// Register custom protocols - -import { protocol } from "electron"; -import path from "path"; - -export function registerFileProtocol(name: string, basePath: string) { - protocol.registerFileProtocol(name, (request, callback) => { - const filePath = request.url.replace(`${name}://`, ""); - const absPath = path.resolve(basePath, filePath); - - callback({ path: absPath }); - }); -} diff --git a/src/main/index.ts b/src/main/index.ts index f6c0b1bbc0..9bda0a8ee4 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -11,13 +11,12 @@ import httpProxy from "http-proxy"; import * as LensExtensionsCommonApi from "../extensions/common-api"; import * as LensExtensionsMainApi from "../extensions/main-api"; import { app, autoUpdater, dialog, powerMonitor } from "electron"; -import { appName, isIntegrationTesting, isMac, isWindows, productName, staticFilesDirectory } from "../common/vars"; +import { appName, isIntegrationTesting, isMac, isWindows, productName } from "../common/vars"; import { LensProxy } from "./lens-proxy"; import { WindowManager } from "./window-manager"; import { ClusterManager } from "./cluster-manager"; import { shellSync } from "./shell-sync"; import { mangleProxyEnv } from "./proxy-env"; -import { registerFileProtocol } from "../common/register-protocol"; import logger from "./logger"; import { appEventBus } from "../common/app-event-bus/event-bus"; import type { InstalledExtension } from "../extensions/extension-discovery/extension-discovery"; @@ -198,8 +197,6 @@ async function main(di: DiContainer) { powerMonitor.on("shutdown", () => app.exit()); - registerFileProtocol("static", staticFilesDirectory); - PrometheusProviderRegistry.createInstance(); initializers.initPrometheusProviderRegistry(); diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index 260a82ccc0..73ceedd867 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -14,9 +14,10 @@ import type { ClusterFrameInfo } from "../common/cluster-frames"; import { clusterFrameMap } from "../common/cluster-frames"; import { IpcRendererNavigationEvents } from "../renderer/navigation/events"; import logger from "./logger"; -import { isMac, productName } from "../common/vars"; +import { isMac, productName, staticFilesDirectory } from "../common/vars"; import { LensProxy } from "./lens-proxy"; import { bundledExtensionsLoaded } from "../common/ipc/extension-handling"; +import path from "path"; function isHideable(window: BrowserWindow | null): boolean { return Boolean(window && !window.isDestroyed()); @@ -257,7 +258,20 @@ export class WindowManager extends Singleton { nativeWindowOpen: true, }, }); - await this.splashWindow.loadURL("static://splash.html"); + + const splashWindowFilePath = path.join(staticFilesDirectory, "splash.html"); + + try { + await this.splashWindow.loadFile(splashWindowFilePath); + } catch (error) { + if (String(error).includes("ERR_FAILED")) { + logger.warn("[WINDOW-MANAGER]: failed to load splash window on first attempt, trying again..."); + // Try again, from reading some issues it seems that trying again immedeiately sometimes works + await this.splashWindow.loadFile(splashWindowFilePath); + } else { + throw error; + } + } } this.splashWindow.show(); }