From 158cb8607a9c58bc3bdabf57ad86fe25538fa52b Mon Sep 17 00:00:00 2001 From: Taea Vogel Date: Mon, 16 Dec 2024 10:59:12 -0500 Subject: [PATCH] add error handling to dev tools installer --- packages/desktop/src/main/main.test.ts | 6 ------ packages/desktop/src/main/main.ts | 13 +++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/desktop/src/main/main.test.ts b/packages/desktop/src/main/main.test.ts index 66d2873457..f4a13e3f21 100644 --- a/packages/desktop/src/main/main.test.ts +++ b/packages/desktop/src/main/main.test.ts @@ -20,7 +20,6 @@ const mockWindowOnce = jest.fn() const mockSetMovable = jest.fn() const mockSetAlwaysOnTop = jest.fn() -const spyApplyDevTools = jest.spyOn(main, 'applyDevTools') const spyCreateWindow = jest.spyOn(main, 'createWindow') const spyGetPorts = jest.spyOn(backendHelpers, 'getPorts') @@ -137,11 +136,6 @@ describe('electron app ready event', () => { expect(setApplicationMenu).toHaveBeenCalledWith(null) }) - // todo - // it('apply devtools logic will trigger one time and ... todo', async () => { - // expect(spyApplyDevTools).toHaveBeenCalledTimes(1) - // }) - it('get ports logic will trigger and will return propper ports', async () => { expect(spyGetPorts).toHaveBeenCalledTimes(1) const getPortsResult = async (): Promise => spyGetPorts.mock.results[0].value diff --git a/packages/desktop/src/main/main.ts b/packages/desktop/src/main/main.ts index 0617bc9e64..9c036f8f0e 100644 --- a/packages/desktop/src/main/main.ts +++ b/packages/desktop/src/main/main.ts @@ -132,12 +132,21 @@ export const applyDevTools = async () => { ] await Promise.all( extensionsData.map(async extension => { - await installer.default(extension.name) + try { + await installer.default(extension.name) + } catch (error) { + logger.error(`Failed to install ${extension.name}:${extension.path}:`, error) + } }) ) + await Promise.all( extensionsData.map(async extension => { - await session.defaultSession.loadExtension(extension.path, { allowFileAccess: true }) + try { + await session.defaultSession.loadExtension(extension.path, { allowFileAccess: true }) + } catch (error) { + logger.error(`Failed to load extension from ${extension.path}:`, error) + } }) ) }