mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix ERR_FAILED for splash screen on windows sometimes (#5534)
This commit is contained in:
parent
e3cb23e111
commit
79c7cb2106
@ -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 });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -11,13 +11,12 @@ import httpProxy from "http-proxy";
|
|||||||
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
import * as LensExtensionsCommonApi from "../extensions/common-api";
|
||||||
import * as LensExtensionsMainApi from "../extensions/main-api";
|
import * as LensExtensionsMainApi from "../extensions/main-api";
|
||||||
import { app, autoUpdater, dialog, powerMonitor } from "electron";
|
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 { LensProxy } from "./lens-proxy";
|
||||||
import { WindowManager } from "./window-manager";
|
import { WindowManager } from "./window-manager";
|
||||||
import { ClusterManager } from "./cluster-manager";
|
import { ClusterManager } from "./cluster-manager";
|
||||||
import { shellSync } from "./shell-sync";
|
import { shellSync } from "./shell-sync";
|
||||||
import { mangleProxyEnv } from "./proxy-env";
|
import { mangleProxyEnv } from "./proxy-env";
|
||||||
import { registerFileProtocol } from "../common/register-protocol";
|
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { appEventBus } from "../common/app-event-bus/event-bus";
|
import { appEventBus } from "../common/app-event-bus/event-bus";
|
||||||
import type { InstalledExtension } from "../extensions/extension-discovery/extension-discovery";
|
import type { InstalledExtension } from "../extensions/extension-discovery/extension-discovery";
|
||||||
@ -198,8 +197,6 @@ async function main(di: DiContainer) {
|
|||||||
|
|
||||||
powerMonitor.on("shutdown", () => app.exit());
|
powerMonitor.on("shutdown", () => app.exit());
|
||||||
|
|
||||||
registerFileProtocol("static", staticFilesDirectory);
|
|
||||||
|
|
||||||
PrometheusProviderRegistry.createInstance();
|
PrometheusProviderRegistry.createInstance();
|
||||||
initializers.initPrometheusProviderRegistry();
|
initializers.initPrometheusProviderRegistry();
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,10 @@ import type { ClusterFrameInfo } from "../common/cluster-frames";
|
|||||||
import { clusterFrameMap } from "../common/cluster-frames";
|
import { clusterFrameMap } from "../common/cluster-frames";
|
||||||
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
import { IpcRendererNavigationEvents } from "../renderer/navigation/events";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { isMac, productName } from "../common/vars";
|
import { isMac, productName, staticFilesDirectory } from "../common/vars";
|
||||||
import { LensProxy } from "./lens-proxy";
|
import { LensProxy } from "./lens-proxy";
|
||||||
import { bundledExtensionsLoaded } from "../common/ipc/extension-handling";
|
import { bundledExtensionsLoaded } from "../common/ipc/extension-handling";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
function isHideable(window: BrowserWindow | null): boolean {
|
function isHideable(window: BrowserWindow | null): boolean {
|
||||||
return Boolean(window && !window.isDestroyed());
|
return Boolean(window && !window.isDestroyed());
|
||||||
@ -257,7 +258,20 @@ export class WindowManager extends Singleton {
|
|||||||
nativeWindowOpen: true,
|
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();
|
this.splashWindow.show();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user