[Question] I can not launch firefox
Hellow there,
I got following errors when firefox is launching.
Source code
const playwright = require('playwright');
browser['firefox'] = await playwright['firefox'].launchPersistentContext("/tmp/user",{
headless: false
});
Error message
[error] Something went wrong with: Error: browserType.launchPersistentContext: Protocol error (Browser.enable): Target closed.
=========================== logs ===========================
<launching> /home/maint/.cache/ms-playwright/firefox-1205/firefox/firefox -no-remote -wait-for-browser -foreground -profile /tmp/maint -juggler-pipe about:blank
<launched> pid=25576
[err] Unable to init server: Broadway display type not supported: localhost:10.0
[err] Error: cannot open display: localhost:10.0
In fact, I did not get these errors when I am using chrome.
Also, I am using playwright with pm2. The OS I am using is ubuntu 18.04LTS.
Do you have any suggestions for this?
Best regards,
My first guess would be that your ssh with X forwarding is not configured correctly. Can you provide more details about the environment and how you launch playwright?
In fact, I did not get these errors when I am using chrome.
Do you run it in headful mode too?
It looks like headful mode is working fine.
maint 343 0.6 0.9 2540408 80528 ? Sl 09:39 0:00 /home/maint/.cache/ms-playwright/firefox-1205/firefox/firefox -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 225335 -parentBuildID 20201109173049 -appdir /home/maint/.cache/ms-playwright/firefox-1205/firefox/browser 32715 true tab
maint 366 1.0 1.1 2561668 90660 ? Sl 09:39 0:00 /home/maint/.cache/ms-playwright/firefox-1205/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 41 -prefMapSize 225335 -parentBuildID 20201109173049 -appdir /home/maint/.cache/ms-playwright/firefox-1205/firefox/browser 32715 true tab
maint 453 0.0 0.0 14168 1156 pts/1 S+ 09:40 0:00 grep --color=auto firefox
maint 32715 5.3 2.6 2909596 213608 ? Ssl 09:39 0:02 /home/maint/.cache/ms-playwright/firefox-1205/firefox/firefox -no-remote -headless -profile /home/maint/.mozilla/firefox -juggler-pipe about:blank
Here is my ssh config.
cat /etc/ssh/sshd_config | grep X11
X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes
# X11Forwarding no
@pavelfeldman @yury-s I could solve it myself by following command.
export DISPLAY=:1
I did not have this setting in .bashrc. So, I added to it. Is that common thing to do? This is first time to set it up.
The way you connfigure X forwarding over ssh will depend on you system and this is not specific for playwright. This post contains some information about the DISPLAY variable. Closing this issue as it's out of Playwright scope.