Hi y'all! 👋
Having some trouble adopting https://figwheel.org/docs/testing.html for the https://developer.chrome.com/articles/new-headless/:
On macOS (13.5, Intel), chrome runs the tests but won't terminate. Looks more like a chrome issue to me to be honest, but maybe I just missed something important.
Anyone successfully running tests using headless chrome (>=115) without chrome processes laying uselessly around afterwards?
Yes. But the main point is "no --repl". And as far as i know, figwheel uses the repl to send a quit (or exit?) to end chrome after the tests. Both together fit into my picture: Chrome doesn't exit because it never receives the quit command because it doesn't listen on the repl (which means: stdin.)
(I'm going to check my assumption with a little script-in-the-middle attack in the next days. Shouldn't be too hard to start chrome in the background, listen for quit on stdin and kill chrome via kill in the first place and a fancy DevTools-Command later.)
Hey! Yes, I just resolved this for our CI recently. The issue (as far as I understand): • chrome is run and immediately exits • figwheel-main doesn’t know chrome isn’t running and just keeps going (because it never receives a success/error msg) Solution I used:
path/to/chrome/bin --headless --remote-debugging-port=9222 :open-urlYou can also try the above with “--headless=new” if you like and, if memory serves, that did work as well
Hi @tkjone,
thanks for your quick reply! 🙇
> The issue (as far as I understand):
> • chrome is run and immediately exits
unfortunately not on my machine: Chrome (headless) never terminates...
> • figwheel-main doesn’t know chrome isn’t running and just keeps going (because it never receives a success/error msg)
... and that's why figwheel-main is quiet happy and exits w/ :figwheel.main.testing/success as expected.
But chrome does not terminate.
Interesting! That is for sure the flip of what I experienced.
So, your tests run and complete, but then the process just doesn't terminate, yes?
Right. You can even put figwheel-main completely aside:
/Applications/Google\ Chrome --headless=new --disable-gpu --no-sandbox
Does not terminate.
Using just --headless (without new) it does terminate as expected. Adding --repl – like in the good ol' days 🙂 – has no effect. (Same is true for adding --remote-debugging-port=9222.)I just can't believe that I'm the only one facing this. 🤔
For fun (to get to a minimal scenario)
• can you remove --disable-gpu and --no-sandbox ?
Test the above.
After the above, can you confirm if you're running a GUI instance of chrome at the same time as you're running your tests?
Additionally, what does your environment-log (provided by figwheel) say (if anything)
Sure. Juggled with these the whole day... just a sec...
First of all: Thanks for your time and help! I owe you a beer. 🍻
> • can you remove --disable-gpu and --no-sandbox ?
Removed.
> can you confirm if you're running a GUI instance of chrome at the same time as you're running your tests?
ps aux | grep -i chrome
No chrome at all before running the tests.
> Additionally, what does your environment-log (provided by figwheel) say (if anything)
With the --remote-debugging-port=9222 set:
DevTools listening on
Without:
[0807/163430.854680:ERROR:(128)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
And no Tests were executed. (That's why I've added --disable-gpu in the first place.)
(Adding / removing --repl has no effect to the results above btw.)> And no Tests where executed. (That's why I've added --disable-gpu in the first place.)
True, this seemed to happen with --headless=new
Do you have async tests? I'm trying to think if there is something in chrome that makes it want to keep runnning because normally it just exits lol
> Do you have async tests?
I have. (And I do use run-tests-async.)
> I'm trying to think if there is something in chrome that makes it want to keep runnning because normally it just exits lol
Do you run macOS as well?
Running --headless=new on a static and simple index.html with no JavaScript at all does not terminate.
> Do you run macOS as well? yes
> Running --headless=new on a static and simple index.html with no JavaScript at all does not terminate.
huh. I wonder what changed with "new". I started digging into the source and then bailed.
ℹ️ Chromium https://bugs.chromium.org/p/chromium/issues/detail?id=1424852: repl stopped working
@tkjone I just find out about this thread and your solution solved the issue for my chrome headless CI tests for both mac and linux: https://github.com/skydread1/flybot.sg/pull/264 So thank you! @ramart my terminal was hanging also for chrome headless tests so maybe my https://github.com/skydread1/flybot.sg/blob/master/tests.cljs.edn can be of any help, hope you already found a solution though!
Aaaand we got an „it‘s by design“ together with a WontFix. (https://bugs.chromium.org/p/chromium/issues/detail?id=1418651)
That's sad, but it sounds like that ticket was about chrome immediately exiting. Wasn't your issue that chrome doesn't exit?