My electron app is randomly redirecting to chrome-error://chromewebdata, and I've no idea why. There's no errors in the console, etc.

When the Electron app first starts, the window opens, and it redirects away from my application to that URL and I see an empty blank white screen. No user interaction is necessary, it just happens when the app starts.

If I open devtools, I can see that window.location.href contains chrome-error://chromewebdata instead of (the Electron app runs using a localhost URL).

I tried deleting the local Electron/Chrome data folder at ~/Library/Application Support/my-app-name and starting over, but no luck.

What are reasons that Chrome (in Electron?) can decide to redirect to chrome-error://chromewebdata?

7

4 Answers

For some reason, your code is trying to navigate to an invalid (non-existing) URL, which then results in window.location.href being chrome-error://chromewebdata.

To reiterate: there is no direct redirection to chrome-error://chromewebdata, but instead to a URL that doesn't exist or is not reachable.

Check if your code causes this navigation (possibly a redirect). It is very useful to inspect the Network tab in DevTools, making sure that "Preserve log" is checked. This should give some indication about what exactly is happening.

4

This is happening for me in my Angular based Electron project. In my case, the problem is that Angular's Webpack server isn't ready to receive requests when I first launch the project. This is only at startup and simple reload can get around it - any live changes to the Angular code will refresh the page without any issue.

This isn't a problem in production as I switch to loading static files in my releases.

To make this a little less annoying, I added a delay to my electron startup:

"start": "concurrently -k \"ng serve\" \"npm run delay && nodemon\"", "delay": "node -e \"setTimeout(() => true, 3000)\"", 

Where:

  • concurrently runs Electron and Angular/Webpack at the same time for faster development.
  • nodemon watches my electron files and restarts the app when I save changes
  • delay just uses node to delay nodemon's first startup (works on all operating systems...)

And just for clarity, my nodemon.json:

{ "watch": ["nucleus"], "ext": "*", "exec": "tsc -p nucleus/tsconfig.json && electron ." } 

view-vhcl-cntr-ctgrs.tpl

i replace this file name like below.

view-vhclcntr-ctgrs.tpl

and it worked....

1

To me it was launchPath issue. As I had multiple electron apps in my workspace (NX). So all I needed to do is to set correct url to launch electron. It was 4200 by default so I updated it to 4202 b/c I already had 4200 & 4201.

let launchPath; if (serve) { require('electron-reload')(__dirname, { electron: require(`${__dirname}/../../../node_modules/electron`), }); launchPath = ' win.loadURL(launchPath); } else { launchPath = url.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: true, }); win.loadURL(launchPath); } console.log('launched electron with:', launchPath); 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy