0x90
0x90

Reputation: 6259

What could cause Electron to not show any errors?

I have taken over an Electron project from another developer.

The problem I am facing is that the project does not show any errors. Even including something like throw "this is an error" does not produce any output on the main process or render process consoles or any sort of standard error popup.

I have checked to confirm that electron-unhandled is not in use and that nothing registers 'uncaughtException'.

What am I missing that could cause this behavior?

Upvotes: 5

Views: 1619

Answers (3)

DevLoverUmar
DevLoverUmar

Reputation: 13933

Are you facing the problem as mentioned in this official thread. You may disable the original event listeners and manage the ELECTRON_BROWSER_WINDOW_ALERT event by my event listener.

Here is the solution

ipcMain.removeAllListeners("ELECTRON_BROWSER_WINDOW_ALERT")
ipcMain.on("ELECTRON_BROWSER_WINDOW_ALERT", (event, message, title)=>{
  console.warn(`[Alert] ** ${title} ** ${message}`)
  event.returnValue = 0 // **IMPORTANT!**
})

Upvotes: 1

factorypolaris
factorypolaris

Reputation: 2847

Search for: unhandledRejection

  • unhandledRejection : This will catch any thrown errors, or non fatal errors you have successfully handled via throw.
  • uncaughtException : This only catches fatal errors or errors that would crash your node instance
  • WebWorkers : There will be yet another console for webworkers if your using those.
  • package.json : Take a look in here at the script executed to start electron or however your starting it... Make sure the console is not being sent to a remote console. This feature would allow for debugging the application via Chrome/Firefox vs the standard console. Pretty common for electron apps. If is done via the startup command.

May look something like this:

process.on('unhandledRejection', function (err) {
   
});

Also, make sure you include any modules in your searching for suppressors as the issue may exist somewhere in the node_modules directory and many IDE's (mine does by default) exclude that directory in indexing/searches.

Upvotes: 4

Daniele Ricci
Daniele Ricci

Reputation: 15797

Another possible reason could be stdout and/or stderr redirection, the problem is this could be achieved by several ways so it's hard to suggest you what to check...

If there is some child_process call to launch a sub-process you could check the stdio array used, or you can check if some low level operation is performed against file descriptors 1 and 2...

Hope this helps.

Upvotes: 3

Related Questions