Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undead headless chrome browsers are hanging around #38

Closed
plocket opened this issue Feb 13, 2024 · 3 comments · Fixed by #39
Closed

Undead headless chrome browsers are hanging around #38

plocket opened this issue Feb 13, 2024 · 3 comments · Fixed by #39
Assignees
Labels
bug Something isn't working priority A combination of urgency and impact

Comments

@plocket
Copy link
Collaborator

plocket commented Feb 13, 2024

We found several Chrome browsers hanging around in someone's container. I believe sometimes ALKiln test are interrupted and don't close the browser properly. Two things to do:

  1. Help people who are currently using this package to close the ghost browsers. If they don't have their own chrome instances that they need, I'm looking at sudo killall -e chrome. I did research it, but I also use it regularly (for Reasons) and it may sound extreme, but it's ok.
  2. Figure out how to take care of it in the future. Here's what I'm thinking, using this stackoverflow as a starting point:
    1. Save the browser PID to a list of browser PIDs in the ALKiln runtime config.
    2. When starting the AitP interview, loop through that list and try to close the processes with those IDs that have also been running for more than a day. We can think about adding an env var for max time for a test run.

There might be other things we can do, for example I'm looking into try/catch/finally for closing the browser. I'm not sure where in cucumber to put it. In Before() where we first create the browser? Currently we don't kill it till AfterAll(), so maybe we should move the start into BeforeAll() and also use a timeout that errors after 1 day.

I think that would probably be good practice, but also unlikely to solve what I think are more likely sources for the problem - internal un-terminated timeouts or the background action ending early/getting interrupted early by the server reloading and doing something funky. Need to experiment a bit.

@plocket plocket added bug Something isn't working priority A combination of urgency and impact labels Feb 13, 2024
@plocket plocket self-assigned this Feb 13, 2024
@plocket
Copy link
Collaborator Author

plocket commented Feb 13, 2024

We may need to take care of this in ALKiln itself with process.

@plocket
Copy link
Collaborator Author

plocket commented Feb 14, 2024

First findings: When we add shell=True to the subprocess.run() in the background action, chrome closes correctly. That confirms that we can recreate the behavior we have locally. Using shell isn't as secure as we want, though, so next is research into how to get the same result without shell.

That does mean we might be able to take care of it properly in this package, which would be ideal.

@plocket
Copy link
Collaborator Author

plocket commented Feb 18, 2024

Currently pursuing using .Popen() with start_new_session, getting the pid, and then using os to kill the new process group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority A combination of urgency and impact
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant