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?
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?
Share Improve this question asked Jun 24, 2020 at 4:40 0x900x90 6,2792 gold badges37 silver badges56 bronze badges 7-
2
Does it not produce any output? Check if your predecessors probably disabled console logging, probably like that:
console.log = () => {}
(or the placed a switch to enable/disable console logging) – Andreas Dolk Commented Jun 24, 2020 at 9:56 - Thanks for this! These are exactly the kind of tricks to disable logging that I am trying to find. Yes, no output at all. Unfortunately, that wasn't it. console.log is not redefined anywhere. Neither is console.error. Are there any similar mon tricks that are used to suppress output in Electron? – 0x90 Commented Jun 25, 2020 at 2:31
- Can you get a console log if you put one into the code yourself? – see sharper Commented Jun 26, 2020 at 4:53
- Could you try a search in the project for 'ELECTRON_RUN_AS_NODE' and 'ELECTRON_NO_ATTACH_CONSOLE'? They can prevent output to console: electronjs/docs/api/… – Remi Commented Jun 26, 2020 at 10:30
- @seesharper Yes. In that case it shows up fine. – 0x90 Commented Jun 30, 2020 at 5:53
3 Answers
Reset to default 4 +50Search 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 mon for electron apps. If is done via the startup mand.
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.
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.
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!**
})