Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devtool won't show in 0.29.0 version #264

Open
frankchen211 opened this issue Dec 30, 2024 · 6 comments
Open

Devtool won't show in 0.29.0 version #264

frankchen211 opened this issue Dec 30, 2024 · 6 comments

Comments

@frankchen211
Copy link

In latest version 0.29.0, the devtool won't open, but 0.28.* versions works.

Tested using this template:

https://github.com/electron-vite/electron-vite-vue

@katalonne
Copy link

yeah, same here, any fix?

@Igloczek
Copy link

you need to wait for window to open before opening devtools

if you are using async/await do something like this

await mainWindow.loadURL(devServerUrl)
mainWindow.webContents.openDevTools()

if not

mainWindow.loadURL(devServerUrl).then(() => mainWindow.webContents.openDevTools())

@frankchen211
Copy link
Author

you need to wait for window to open before opening devtools

if you are using async/await do something like this

await mainWindow.loadURL(devServerUrl)
mainWindow.webContents.openDevTools()
if not

mainWindow.loadURL(devServerUrl).then(() => mainWindow.webContents.openDevTools())

Still won't work, even try to open the devtool from menu.

@manifoldtimblin
Copy link

I'm having this issue on Linux, but my co-workers who use macOS are unaffected.

@andersk
Copy link

andersk commented Mar 2, 2025

I see this problem too. Bisection shows it was introduced by commit 638d0f3, specifically this part of the change:

--- a/src/index.ts
+++ b/src/index.ts
@@ -165,7 +168,10 @@ export async function startup(
   await startup.exit()
 
   // Start Electron.app
-  process.electronApp = spawn(electronPath, argv, { stdio: 'inherit', ...options })
+  process.electronApp = spawn(electronPath, argv, {
+    stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
+    ...options,
+  })
 
   // Exit command after Electron.app exits
   process.electronApp.once('exit', process.exit)

@andersk
Copy link

andersk commented Mar 2, 2025

Minimal reproduction on Linux from an empty directory:

electron/main.js

import { app, BrowserWindow } from "electron";

app.whenReady().then(async () => {
  const win = new BrowserWindow();
  await win.loadURL("about:blank");
  win.webContents.openDevTools();
});

package.json

{
  "main": "dist-electron/main.js",
  "dependencies": {
    "electron": "^34.3.0",
    "vite": "^5.4.14",
    "vite-plugin-electron": "^0.29.0"
  }
}

vite.config.js

import electron from "vite-plugin-electron/simple";

export default {
  plugins: [
    electron({
      main: {
        entry: "electron/main.js",
      },
    }),
  ],
};

Run npm i; npx vite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants