You are not logged in.

#1 2021-03-30 12:56:16

Registered: 2020-11-05
Posts: 15

Electron apps are not being able to open external links

None the electron apps I have (Discord, Slack, VSCode) are able to open any links in Firefox. It seems like other applications have no trouble with this.

$ xdg-settings get default-web-browser         

$ xdg-open
// opens the page as expected

Any ideas why this might be happening? How would I troubleshoot this?

Changing the default browser with xdg-settings to chromium.desktop seems to work as expected. It does not work with firefox for some reason.

Last edited by Celsiuss (2021-03-30 15:36:54)


#2 2021-04-23 16:00:54

Registered: 2012-08-06
Posts: 26

Re: Electron apps are not being able to open external links

Looks like this is (at least in case) yet another buggy Wayland thing. I found a solution thanks to this thread.

cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox-wayland-fix.desktop

Edit ~/.local/share/applications/firefox-wayland-fix.desktop and change the first Exec line to this:

Exec=env GDK_BACKEND=wayland /usr/lib/firefox/firefox %u


xdg-settings set default-web-browser firefox-wayland-fix.desktop


#3 2022-08-25 05:06:37

Registered: 2018-11-12
Posts: 21

Re: Electron apps are not being able to open external links

Sorry for the necrobump, I also had troubles opening links in Slack and this comes up as one of the first Google results. I had no success with the other solutions but I found what's going on in my case, hopefully this helps someone.

It turns out that when Electron tries to open a link, it uses xdg-open, but it launches it with file descriptors 1 (stdout) and 2 (stderr) not associated to anything - you can check this by looking around /proc/N/fd.
So after Firefox is launched, they get associated to something else ("random" devices, sockets) and when Firefox writes something to them, it can hang depending on various factors.

My workaround for this is to create a wrapper for xdg-open to set up stdout/stderr, i.e. create a file somewhere like /usr/local/bin/xdg-open (don't forget to chmod +x) with those contents:

set -eu

# Electron apps do not set up stdout/stderr when launching links through
# xdg-open, which can cause Firefox & co. to hang, so set them up here.
[ -e /dev/fd/1 ] || exec 1>/dev/null
[ -e /dev/fd/2 ] || exec 2>/dev/null

exec /usr/bin/xdg-open "$@"

EDIT: The above problem is related to A simpler workaround is to launch the Electron program with stdout/stderr redirected to a file or /dev/null, e.g. like "slack >/dev/null 2>/dev/null".

Last edited by joanbrugueram (2022-08-31 23:32:00)


#4 2022-08-25 05:57:05

Registered: 2012-09-03
Posts: 53,336

Re: Electron apps are not being able to open external links

This should probably be in the wiki,


Board footer

Powered by FluxBB