Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Electron exits without emiting render-process-gone event

When I press a button on a certain website loaded in a BrowserView, the electron app exits. It's obviously a crash, but it doesn't emit the render-process-gone neither on the BrowserWindow (renderer) or the BrowserView. It just quits. But window-all-closed is emited

app.on('ready', () => {
  app.on('render-process-gone', (e, webContents, details) => {
    console.log('render-process-gone', details);
  });

  const win = new BrowserWindow({
    frame: false,    
    webPreferences: {
      worldSafeExecuteJavaScript: true,
      nodeIntegration: true,
      webviewTag: false,
      enableRemoteModule: false,
    }
  });

  win.loadURL('file://' + __dirname + '/renderer.html');

  const view = new BrowserView({
    webPreferences: {
      preload: 'preload.js'
      worldSafeExecuteJavaScript: true,
      nodeIntegration: false,
      nodeIntegrationInSubFrames: true,
      enableRemoteModule: false,
    }
  });

  view.webContents.loadURL('http://website.com');

  view.webContents.on('render-process-gone', (e, details) => {
    console.log('render-process-gone', details);
  });

  win.setBrowserView(view);  

});

app.on('window-all-closed', () => {
  console.log('exiting...');
  app.quit();
});

Is there a way to find out what could be causing this?


update: I added sandbox: true to the webPreferences and now it doesn't crash anymore!

like image 464
Alex Avatar asked Oct 28 '25 01:10

Alex


2 Answers

Emitted when the renderer process crashes or is killed.

**Deprecated:** This event is superceded by the `render-process-gone` event
which contains more information about why the render process dissapeared. It
isn't always because it crashed.  The `killed` boolean can be replaced by
checking `reason === 'killed'` when you switch to that event.

#### Event: 'render-process-gone'

Returns:

* `event` Event
* `details` Object
  * `reason` String - The reason the render process is gone.  Possible values:
    * `clean-exit` - Process exited with an exit code of zero
    * `abnormal-exit` - Process exited with a non-zero exit code
    * `killed` - Process was sent a SIGTERM or otherwise killed externally
    * `crashed` - Process crashed
    * `oom` - Process ran out of memory
    * `launch-failure` - Process never successfully launched
    * `integrity-failure` - Windows code integrity checks failed

Emitted when the renderer process unexpectedly dissapears.  This is normally
because it was crashed or killed.
  • Added new render-process-gone event on app to replace the renderer-process-crashed event. #23560
  • Added new render-process-gone event to replace the crashed event. #23096

REF: https://github.com/electron/electron/pull/23096

https://github.com/electron/electron/pull/23560

like image 121
tpikachu Avatar answered Oct 30 '25 15:10

tpikachu


I was having the same error, even the reason for 'Renderer-Process-Gone' was coming undefined. Just did npm install electron@latest and sandbox = true.

The error was not being caught by mainWindow.webContents.on() rather by app.on()

like image 24
August Avatar answered Oct 30 '25 15:10

August



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!