Little problem - Error: write EPIPE
Hello, Thanks for creating this great application. I have a little problem and I'm just curious if You know what can be the cause of this problem I have Linux Ubuntu 22 with KDE instead of Gnome, below is my information, I can provide more information if necessary uname -a Linux PC 6.8.0-60-generic #63~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 22 19:00:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
This problem occurs when I set ElectronMail application as a startup application to start after Linux boots up Then electron-mail freezes and this error occurs Error: write EPIPE. But when I end the process of electron-mail and start electron-mail again manually, not as a startup application, then ElectronMail works fine. So this problem occurs only when electron-mail is set as a startup application, so it is not a big problem
Below full log of this error Error: write EPIPE at afterWriteDispatched (node:internal/stream_base_commons:161:15) at writeGeneric (node:internal/stream_base_commons:152:3) at Socket._writeGeneric (node:net:958:11) at Socket._write (node:net:970:8) at writeOrBuffer (node:internal/streams/writable:572:12) at _write (node:internal/streams/writable:501:10) at Writable.write (node:internal/streams/writable:510:10) at console.value (node:internal/console/constructor:303:16) at console.warn (node:internal/console/constructor:383:26) at resolveProtonAppTypeFromUrlHref (/opt/ElectronMail/resources/app.asar/app/electron-main/index.cjs:77903:17)
The report is detailed enough, thanks.
I have not seen this one before. It looks like a racing issue (some actions supposed to act sequentially being run in unpredicted order, this is normally a bug in the design/implementation).
Consider adding a small delay before it automatically starts. Like by putting Exec=sleep 10s && /opt/ElectronMail/electron-mail-like command to autostart .desktop shortcut file.
Consider adding a small delay before it automatically starts. Like by putting
Exec=sleep 10s && /opt/ElectronMail/electron-mail-like command to autostart.desktopshortcut file.
If there is no success, consider adding Login delay range (seconds) value on the account edit form, like 10-15 (locate it inside the "Advanced Options" block). See below screenshot if needed.
hi :) thank You for the information and the hints. I tried adding long delays for application startup in Linux boot-up script and tried this account setting of Login delay range of 10-15 in seconds but unfortunately it didn't help
I found out the cause of this problem.
It seems that both plasma-systemmonitor and ElectronMail applications can crash after python script, that started these applications, reaches its end
The fix was to change in my python script
stdout=subprocess.PIPE, stderr=subprocess.PIPE
into that
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
I had a Linux startup bash script .sh which was launching a python script .py which is launching all startup applications (I like Python features)
I intended to make Python script start all necessary applications and then quit, hoping that all launched applications will continue working with exited Python script that started them
It seems that some applications work fine this way, like Konsole, gedit, web browsers, gnome-system-monitor, I didn't notice this hidden problem
I noticed crashes for only plasma-systemmonitor and ElectronMail applications started from this python script. These applications work fine up until python script (that started them) exits
When python script starts the application, the python script PID is assigned as a parent PID for started application
After Python script ends, the parent PID for started application gets changed from the PID of that python script to PID equal to 1 which is PID of systemd /sbin/init splash
Child process of exited parent process became orphaned and got adopted by init/systemd (PID 1).
When I start plasma-systemmonitor or ElectronMail application manually then the parent process was plasma-shell, which doesn't exit while Linux KDE is running, so applications didn't get orphaned
Initially I was launching applications in python script this way
self.process = subprocess.Popen(
[self.command, self.command_parameters]
stdout=subprocess.PIPE, stderr=subprocess.PIPE, # create a pipe between child application process and python script that starts it
)
The fix to this problem EPIPE for me is to launch application in python script this way, now plasma-systemmonitor and ElectronMail don't crash after python script reaches its end
self.process = subprocess.Popen(
[self.command, self.command_parameters]
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, # to avoid creating a pipe between child application process and python script that starts it
)
This can probably also be the fix for this problem but it didn't work for me. To detach child process by setting a new session ID (SID) using setsid
self.process = subprocess.Popen(
['setsid', self.command, self.command_parameters]
start_new_session=True, # start_new_session should cause the new process to be detached from parent process so that it can exist independently of parent process
preexec_fn=os.setsid
)
I'm wondering if there is a way to modify ElectronMail application so that it can ignore situation when parent process that started ElectronMail process exits and output pipe was still opened, but I'm not very good in TypeScript I might try to find some other way to fix this and write it here, generally, thank You for this useful application