From 7b1223d2c58007ef1638cfc658cf272875833693 Mon Sep 17 00:00:00 2001 From: Its-treason <39559178+Its-treason@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:40:01 +0200 Subject: [PATCH] feat(#740): Add hints for local bruno setup - Custom error when opening bruno in the browser - Custom error when starting electron without the web server running - Force Next dev server to use port 3000 --- packages/bruno-app/package.json | 2 +- packages/bruno-app/src/pages/_app.js | 9 +++++++++ packages/bruno-electron/src/index.js | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/package.json b/packages/bruno-app/package.json index b23d7459..c3f82569 100644 --- a/packages/bruno-app/package.json +++ b/packages/bruno-app/package.json @@ -3,7 +3,7 @@ "version": "0.3.0", "private": true, "scripts": { - "dev": "cross-env ENV=dev next dev", + "dev": "cross-env ENV=dev next dev -p 3000", "build": "next build && next export", "start": "next start", "lint": "next lint", diff --git a/packages/bruno-app/src/pages/_app.js b/packages/bruno-app/src/pages/_app.js index 0b2f9c3a..0437555c 100644 --- a/packages/bruno-app/src/pages/_app.js +++ b/packages/bruno-app/src/pages/_app.js @@ -41,6 +41,15 @@ function MyApp({ Component, pageProps }) { return null; } + if (!window.ipcRenderer) { + return ( +
+ Error: "ipcRenderer" not found in window object. You most likely opened Bruno inside your web browser. Bruno + only works within Electron, you can start Electron using "npm run dev:electron". +
+ ); + } + return ( diff --git a/packages/bruno-electron/src/index.js b/packages/bruno-electron/src/index.js index f7cb3acc..602517b5 100644 --- a/packages/bruno-electron/src/index.js +++ b/packages/bruno-electron/src/index.js @@ -67,7 +67,21 @@ app.on('ready', async () => { slashes: true }); - mainWindow.loadURL(url); + mainWindow.loadURL(url).catch((reason) => { + console.error(`Error: Failed to load URL: "${url}" (Electron shows a blank screen because of this).`); + console.error('Original message:', reason); + if (isDev) { + console.error( + 'Could not connect to Next.Js dev server, is it running?' + + ' Start the dev server using "npm run dev:web" and restart electron' + ); + } else { + console.error( + 'If you are using an official production build: the above error is most likely a bug! ' + + ' Please report this under: https://github.com/usebruno/bruno/issues' + ); + } + }); watcher = new Watcher(); const handleBoundsChange = () => {