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

[Bug]: React devtools doesn't attach to devtools on launch, reload needed #41613

Open
3 tasks done
SantiagoChiappe opened this issue Mar 17, 2024 · 4 comments
Open
3 tasks done
Labels
29-x-y bug 🪲 has-repro-comment Issue has repro in comments

Comments

@SantiagoChiappe
Copy link

SantiagoChiappe commented Mar 17, 2024

Preflight Checklist

Electron Version

29.1.4

What operating system are you using?

Windows

Operating System Version

Windows 11 Home 23H2

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

When I launch my Electron app on developer mode, React Devtools are installed and attached to my app.

Actual Behavior

React Devtools are installed, but not attached to my app. A manual reload or force reload is required to attach it. Same problem if I installed React Devtools manually from Chrome extensions, have to reload manually.
bug01
bug02
bug03
bug04

Testcase Gist URL

No response

Additional Information

My code :

// Import required modules
const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-devtools-installer');
const path = require('path');
const { app, BrowserWindow } = require('electron');

// Initialize mainWindow variable
let mainWindow;

// Function to create the main window
const createWindow = async () => {
  const isDev = await import('electron-is-dev');

  // Configure the main window
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true, // Enable Node.js integration
      enableRemoteModule: true, // Enable remote module
      contextIsolation: false, // Disable context isolation
      autoHideMenuBar: true, // Auto-hide menu bar
      devTools: isDev.default, // Show DevTools in development
    },
  });

  // Hide the menu bar
  mainWindow.setMenuBarVisibility(true);

  // Load the appropriate URL based on the environment
  mainWindow.loadURL(
    isDev.default
      ? 'http://localhost:3000' // Development URL
      : `file://${path.join(__dirname, '../build/index.html')}` // Production URL
  );
};

// Create the main window when the app is ready
app.whenReady().then(() => {
  installExtension(REACT_DEVELOPER_TOOLS,  { loadExtensionOptions: { allowFileAccess: true }})
      .then((name) => {
        console.log(`Added Extension: ${name}`);
        // Create the window and the React application
        createWindow();
      })
      .catch((err) => console.log('An error occurred: ', err));
});

// Quit the app when all windows are closed (except on macOS)
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

// Create a new window when the app is activated (macOS)
app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow();
  }
});

I tried also reloading the window on my code or adding a timer to reload the window but without success.

@jkleinsc jkleinsc added has-repro-comment Issue has repro in comments 29-x-y labels Mar 19, 2024
@erikian
Copy link
Member

erikian commented Apr 10, 2024

@SantiagoChiappe are you getting an error similar to this (reported in #37876 (comment)) in your main process?

[91044:0308/100700.690484:ERROR:CONSOLE(2)] "Electron sandboxed_renderer.bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (2)
[91044:0308/100700.690537:ERROR:CONSOLE(2)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (2)

@SantiagoChiappe
Copy link
Author

@SantiagoChiappe are you getting an error similar to this (reported in #37876 (comment)) in your main process?

[91044:0308/100700.690484:ERROR:CONSOLE(2)] "Electron sandboxed_renderer.bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (2)
[91044:0308/100700.690537:ERROR:CONSOLE(2)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (2)

Yes I do, only when opening devtools. I also got other errors when I reload the app using View -> Reload, but then react devtools appear as I mentioned previously :

[1] [73616:0410/004950.275:ERROR:CONSOLE(1)] "uniqueContextId not found", source: devtools://devtools/bundled/core/sdk/sdk.js (1)
[1] [73616:0410/004950.275:ERROR:CONSOLE(1)] "Extension server error: Inspector protocol error: uniqueContextId not found", source: devtools://devtools/bundled/models/extensions/extensions.js (1)
[1] [73616:0410/004950.278:ERROR:CONSOLE(1)] "Received error with code E_PROTOCOLERROR while checking if react has loaded: "Inspector protocol error: %s"", source: chrome-extension://deachpobkibmlfmamelbofgimdagiiob/build/main.js (1)```

@louispelarrey
Copy link

Got the same issue

@Jurin
Copy link

Jurin commented Apr 22, 2024

Exact same issue but with Vue devtools with the exception that it will not load even after reloading. Same error when trying to open devtools.

[24844:0422/101748.810:ERROR:CONSOLE(1)] "Request Autofill.enable failed. {"code":-32601,"message":"'Autofill.enable' wa
sn't found"}", source: devtools://devtools/bundled/core/protocol_client/protocol_client.js (1)
[24844:0422/101748.903:ERROR:CONSOLE(2)] "Electron renderer.bundle.js script failed to run", source: node:electron/js2c/
renderer_init (2)
[24844:0422/101748.903:ERROR:CONSOLE(2)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.ite
rator))", source: node:electron/js2c/renderer_init (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
29-x-y bug 🪲 has-repro-comment Issue has repro in comments
Projects
No open projects
Status: 👍 Does Not Block Stable
Development

No branches or pull requests

5 participants