diff options
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts')
-rw-r--r-- | packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts b/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts index 8d557c4..da40a56 100644 --- a/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts +++ b/packages/main/src/infrastructure/electron/impl/lockWebContentsToFile.ts | |||
@@ -21,6 +21,7 @@ | |||
21 | import type { WebContents } from 'electron'; | 21 | import type { WebContents } from 'electron'; |
22 | 22 | ||
23 | import getLogger from '../../../utils/getLogger'; | 23 | import getLogger from '../../../utils/getLogger'; |
24 | import isErrno from '../../../utils/isErrno'; | ||
24 | import type Resources from '../../resources/Resources'; | 25 | import type Resources from '../../resources/Resources'; |
25 | 26 | ||
26 | const log = getLogger('lockWebContentsToFile'); | 27 | const log = getLogger('lockWebContentsToFile'); |
@@ -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 | */ |
37 | export default function lockWebContentsToFile( | 39 | export 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 | } |