[Feature Request]: Opt-out of/ suppress ‘unsafe-eval’ warning

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

We use 'eval-source-map' for our source maps in Webpack, it’s the only thing that gives us reasonable rebuild times. But with versions of Electron 9.x and up, a devTools window appears for every window that allows 'unsafe-eval'.

Unfortunately this becomes problematic when your app creates three windows at startup, because the three windows each get their own devTools instance. They’re tedious to close, slow to load, and override our built-in method for managing which window to show devTools for.

Proposed Solution

Option to disable the warning AND the auto-opening of devTools. ELECTRON_DISABLE_SECURITY_WARNINGS=1 suppresses the warning but the devTools window still opens, which is the worst of both worlds.

Alternatives Considered

  win.on('ready-to-show', evt => {
    if (win.devToolsIsOpened()) win.closeDevTools();
    if (showDevtoolsFor['winName'])
      win.openDevTools();
  });

The above infinitely loops opening/closing devtools. Adding a setTimeout of 1000ms doesn’t help either, it still loops.

Even without the infinite looping, it’s rather jarring to have the windows appear and disappear one after another, for a total of six flashes across the screen on every reload of the app – and then the devtools to appear as we’d like after that.

If we have to delay opening devtools, that also means that code may execute before we can debug it.

There might be some way to make it work with 'devtools-closed', but it would be highly convoluted because then we’d have to track whether it was the initial close of the devtools, and then open the devtools we want in response. Because it we didn’t track whether it was the initial open, we’d be unable to ever close the devtools without them re-opening.


Also considered not using eval-source-map for our source maps, but everything else is so god-awfully slow. The next fastest option that reproduces the original code is like twenty times slower.

Additional Information

Unrelated: The new textareas for the issue template can’t be resized vertically (at least in Firefox) which makes writing rather unpleasant.

1 possible answer(s) on “[Feature Request]: Opt-out of/ suppress ‘unsafe-eval’ warning

  1. a devTools window appears for every window that allows ‘unsafe-eval’.

    Electron does not have code to do this, it will be appcode or code inside one of your modules. If this is not the case, please provide a standalone minimal repro that demonstrates the devtools window opening and this issue can be re-opened.