aerokube/moon

Sessions randomly stuck

alex-buyanov opened this issue · 4 comments

TLDR: when I am running tests on Moon, oftentimes they get stuck. In VNC, I see that browser is open and page is loaded but test is doing nothing.

I use Playwright Java + TestNG. What happens is that usually tests start okay, but at some point one or two sessions just stay there in Moon doing nothing. It is important to note, that tests are running in parallel with @DataProviders also set to parallel executions. Each test gets its browser from a "browser pool": Java hashmap which allows access by only one thread at a time.

When tests get stuck, I can check running processes and see if nodejs instances spawned by Playwright are still there. If I kill stuck processes, then Playwright obviously fails the test, because connection to browser is broken.

I thought that this is caused by Playwright itself, but that is not true: running tests in local browsers never fails and no browsers get stuck.

The fact that I fail to see the pattern makes the issue harder: it is a new random test every time, whose session gets stuck :(

Appreciate any advice on debugging this.

PS: can't share the repo, and even if I could, you won't be able to connect to company's Moon.

@alex-buyanov is your Java code finishing its work? Moon closes Playwright sessions only when respective web-socket connection from your code is closed. If your code is stuck, then Moon session will be stuck too until you stop this code.

Nope. That's exactly the problem: a random test (or a couple of them) just get stuck during interactions between Playwright and Moon indefinitely.

I suspect that there is some kind of clash between TestNG threading model, Playwright Java and Moon. And I have no idea how to troubleshoot this :D

Running tests sequentially (non-parallel) eliminates the issue, but that's not a solution. Running tests without Moon also helps, but this is not a solution either.

I thought maybe somebody else have seen such an issue, but Google has failed me.

@alex-buyanov what is the version of playwright-java library and what playwright version do you request in Moon URL? Both versions should match.

I use Playwright 1.38.0 as of now. And I request the same version from Moon: I made sure versions are the same by checking the test code + actually looking at Moon's GUI (sessions have labels with Playwright version). Everything matches.

I also tried using older versions of Playwright, but that did not have any effect.