Fork me on GitHub
#figwheel-main
<
2023-08-07
>
RAMart10:08:42

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?

athomasoriginal13:08:01

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-url

athomasoriginal13:08:43

You can also try the above with “--headless=new” if you like and, if memory serves, that did work as well

RAMart14:08:23

Hi @U6GNVEWQG, 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.

athomasoriginal14:08:27

Interesting! That is for sure the flip of what I experienced.

athomasoriginal14:08:58

So, your tests run and complete, but then the process just doesn't terminate, yes?

RAMart14:08:14

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.)

RAMart14:08:36

I just can't believe that I'm the only one facing this. :thinking_face:

athomasoriginal14:08:48

For fun (to get to a minimal scenario) • can you remove --disable-gpu and --no-sandbox ? Test the above.

athomasoriginal14:08:28

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?

athomasoriginal14:08:47

Additionally, what does your environment-log (provided by figwheel) say (if anything)

RAMart14:08:52

Sure. Juggled with these the whole day... just a sec...

👍 2
RAMart14:08:53

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.)

athomasoriginal14:08:31

> 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

athomasoriginal14:08:43

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

RAMart15:08:46

> 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.

athomasoriginal15:08:14

> Do you run macOS as well? yes

athomasoriginal15:08:20

> 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.

RAMart18:08:44

Aaaand we got an „it‘s by design“ together with a WontFix. (https://bugs.chromium.org/p/chromium/issues/detail?id=1418651)

athomasoriginal20:08:08

That's sad, but it sounds like that ticket was about chrome immediately exiting. Wasn't your issue that chrome doesn't exit?

RAMart06:08:51

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.)

Loic08:10:52

@U6GNVEWQG 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! @U1Z4D5SSV 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!

🎉 1