aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts')
-rw-r--r--packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts b/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts
index 48b1bf0..338c845 100644
--- a/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts
+++ b/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts
@@ -20,8 +20,9 @@
20 20
21import type { WebContents } from 'electron'; 21import type { WebContents } from 'electron';
22 22
23import { getLogger } from '../../../utils/log'; 23import getLogger from '../../../utils/getLogger.js';
24import type Resources from '../../resources/Resources'; 24import isErrno from '../../../utils/isErrno.js';
25import type Resources from '../../resources/Resources.js';
25 26
26const log = getLogger('lockWebContentsToFile'); 27const log = getLogger('lockWebContentsToFile');
27 28
@@ -33,8 +34,9 @@ const log = getLogger('lockWebContentsToFile');
33 * @param resources The resource handle associated with the paths and URL of the application. 34 * @param resources The resource handle associated with the paths and URL of the application.
34 * @param filePath The path to the file in the render package to load. 35 * @param filePath The path to the file in the render package to load.
35 * @param webContents The webContents to lock. 36 * @param webContents The webContents to lock.
37 * @returns A promise that resolves when the webpage is loaded.
36 */ 38 */
37export default function lockWebContentsToFile( 39export default async function lockWebContentsToFile(
38 resources: Resources, 40 resources: Resources,
39 filePath: string, 41 filePath: string,
40 webContents: WebContents, 42 webContents: WebContents,
@@ -55,5 +57,13 @@ export default function lockWebContentsToFile(
55 } 57 }
56 }); 58 });
57 59
58 return webContents.loadURL(pageURL); 60 try {
61 await webContents.loadURL(pageURL);
62 } catch (error) {
63 // Chromium will throw `ERR_ABORTED` when the vite dev server is still initializing,
64 // but will load the page nevertheless.
65 if (!isErrno(error, 'ERR_ABORTED') || !pageURL.startsWith('http:')) {
66 throw error;
67 }
68 }
59} 69}