ProtonMail / proton-bridge

Proton Mail Bridge application
GNU General Public License v3.0
1.18k stars 157 forks source link

Bridge takes 3 minutes to startup unless gnome-keyring-daemon is killed beforehand #472

Open g-regex opened 7 months ago

g-regex commented 7 months ago

Hi! Since I have started using proton-mail-bridge (about 2 years ago), I have been experiencing this issue with every version of the bridge (currently 3.10.0):

When gnome-keyring-daemon is running, the bridge takes about 3 minutes to startup, reporting warnings that it failed to add test credentials. If gnome-keyring-daemon is not running, the bridge starts up without any delay.

Behaviour with gnome-keyring-daemon running (added the date command to show the delay):

$ date +%H:%M:%S && proton-mail-bridge -c
23:02:43
INFO[0000] Migrating keychain helper
WARN[Apr 19 23:03:44.539] Failed to add test credentials to keychain    error="timed out after 10s" helper="*keychain.SecretServiceDBusHelper"
WARN[Apr 19 23:05:59.136] Failed to add test credentials to keychain    error="Error calling StartServiceByName for org.freedesktop.secrets: Timeout was reached" helper="*secretservice.Secretservice"

            Welcome to Proton Mail Bridge interactive shell

Behaviour when killing gnome-keyring-daemon beforehand:

$ date +%H:%M:%S && killall gnome-keyring-daemon && proton-mail-bridge -c
23:19:27
INFO[0000] Migrating keychain helper

            Welcome to Proton Mail Bridge interactive shell

System information

proton-mail-bridge version: 3.10.0 (built from source) System uname: Linux-6.6.21-gentoo-x86_64-Intel-R-_Core-TM-_i5-5250U_CPU_@_1.60GHz-with-glibc2.38

Versions of dependencies:

I have searched the GitHub issues but could not find anything similar. Is this a known problem and, if so, is there a better workaround (or fix) than killing gnome-keyring-daemon?

droople1 commented 1 month ago

I am also having this problem.

droople1 commented 1 month ago

If the gnome-keyring-daemon is running, then the bridge hangs after putting Creating keychain list in the logs, where it waits to timeout. I traced the timeout to here.

So this could be go keychain's problem.

Edit: My mistake, it should be this fork of go keychain.

droople1 commented 1 month ago

I've been able to confirm that this problem occurs outside the context of protonmail-bridge. Running the function

https://github.com/ProtonMail/proton-bridge/blob/df78e292341043b196c2aba812fc48d2c2e8501b/pkg/keychain/helper_dbus_linux.go#L42

in isolation (go-keychain was the only import) resulted in a timeout if gnome-keyring-daemon was running, and did not result in a timeout if it wasn't. I was able to confirm this for the upstream version of go-keychain as well.

This doesn't address the problem that protonmail-bridge will make you wait for the timeout even if you would prefer to use another helper.

g-regex commented 4 weeks ago

@droople1, is your dbus session started properly?

Check whether DBUS_SESSION_BUS_ADDRESS is set. It wasn't set in my case. I'm not on a desktop environment such as Gnome or KDE and launched my window manager / wayland compositor with a command like exec i3 or exec Hyprland. To make the dbus session visible to all children of the window manager, one should start it with a command like exec dbus-launch --exec-with-session i3.

With these changes, the issue disappears for me.

It might be useful to let the bridge check whether DBUS_SESSION_BUS_ADDRESS is set and let it print a warning otherwise.