electron-devtools-installer icon indicating copy to clipboard operation
electron-devtools-installer copied to clipboard

React Devtools only appears after a reload

Open elvince opened this issue 1 year ago • 13 comments

[!IMPORTANT] This is an upstream issue, see https://github.com/electron/electron/issues/41613


Hi all,

Thanks for the repo, it is quite straight forward to setup.

However, I can't get the tools to popup in the devtool page until I reload the main page.

If I await installExtension(REACT_DEVELOPER_TOOLS, true), the tools are not loaded at first launch, I need to reload them. If I manually load them await session.defaultSession.loadExtension, evertyhing load fine from scratch.

Any idea how solve this? Maybe a missing await in the installation process? It seems to be a race condition.

Thanks

elvince avatar Feb 09 '24 14:02 elvince

I am seeing this same issue as well with latest version of electron and electron-devtools-installer.

JordanDC2 avatar Feb 28 '24 14:02 JordanDC2

I am seeing this same issue as well with latest version of electron and electron-devtools-installer.

Did you manage to find a fix?

vasilecampeanu avatar Mar 09 '24 17:03 vasilecampeanu

I am having this issue too.

session.defaultSession.getAllExtensions().map(e => {
  if (e.name === 'React Developer Tools') {
    session.defaultSession.loadExtension(e.path);
  }
});

This works, but should load automatically I think.

ehellman avatar Mar 18 '24 16:03 ehellman

Seeing the same issue here. I simply run a reload after a timeout and it seems to do the trick

DEV && setTimeout(() => {
    mainWindow.reload();
}, 500);

pjmdesi avatar Apr 12 '24 20:04 pjmdesi

I am having this issue too.

session.defaultSession.getAllExtensions().map(e => {
  if (e.name === 'React Developer Tools') {
    session.defaultSession.loadExtension(e.path);
  }
});

This works, but should load automatically I think.

Why not just load all?

  session.defaultSession.getAllExtensions().map((e) => {
     session.defaultSession.loadExtension(e.path)
   })

maoryadin avatar May 26 '24 14:05 maoryadin

i cant make any extension appear no matter what i do im on electron 31 and i cant find any solution for this

aymengraoui avatar Jun 19 '24 16:06 aymengraoui

Same issue as aymengraoui.

aluminum1 avatar Jul 08 '24 13:07 aluminum1

I pasted this workaround and an explanation over in another issue: https://github.com/MarshallOfSound/electron-devtools-installer/issues/238#issuecomment-2227172999

async function loadDevtools() {
  const edi = await import('electron-devtools-installer');
  const installExtension = edi.default.default;
  await installExtension(edi.REDUX_DEVTOOLS);
  await installExtension(edi.REACT_DEVELOPER_TOOLS);

  // hack because extension service workers aren't loaded until after first launch
  const win = new BrowserWindow({
    show: false,
    webPreferences: { devTools: true },
  });
  await win.loadURL('about:blank');
  win.webContents.openDevTools({ mode: 'detach', activate: false });
  await new Promise<void>((resolve, reject) => {
    let checksLeft = 300;
    const interval = setInterval(() => {
      const all = session.defaultSession.serviceWorkers.getAllRunning();
      if (Object.keys(all).length > 0) {
        clearInterval(interval);
        resolve();
      } else {
        checksLeft -= 1;
        if (checksLeft <= 0) {
          clearInterval(interval);
          reject(new Error('react dev tools failed to load a service worker'));
        }
      }
    }, 10);
  });
  win.close();
}

danthegoodman avatar Jul 14 '24 02:07 danthegoodman

Hi @danthegoodman thanks for the workaround it didn't work for me, the problem with the workers i bumper the checks to 10000 and nothing i might dig into this workaround if i have time, for now i gave up on this i installed extensions i need globally and linked them to my app using urls

aymengraoui avatar Jul 14 '24 11:07 aymengraoui

You should load the react extension before creating the window. It works for me.

jadyyang avatar Sep 09 '24 01:09 jadyyang

electron 32 could not load any extensions(React DevTools, Vue3 DevTools, Redux DevTools). I had installed them before creating(invoking installExtension method) electron window. it is frustrating...

Dedicatus546 avatar Sep 20 '24 08:09 Dedicatus546