Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Cross-platform browser process killer #110

Merged
merged 3 commits into from
Nov 15, 2021
Merged

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Nov 12, 2021

This PR adds a cross-platform browser process killer.

  • k6Throw kills any lingering browser processes in a cross-platform way.
  • Saves the process ID to the context when launching a new browser.

We need to update k6common.Throw to our k6Throw for this to work stable. And I manually tested this with 100 browsers on my Mac. It cleaned up all the lingering processes. Automated tests are missing for now. I'm planning to do these in a separate PR.

As I said in the PR this is a temporary fix:
#93 (comment)

Closes: #93

Copy link
Member

@robingustafsson robingustafsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, yes this is basically what I thought of as a temporary fix. I'll let Ivan do a more thorough code review 🙂 ...but LGTM.

@inancgumus inancgumus force-pushed the feat/gc-browser-processes branch from b53b791 to cb817d0 Compare November 12, 2021 13:22
* Saves the process ID to the context when launching
  a new browser.

* k6Throw helper function kills the lingering processes
  before throwing a k6 error.
@inancgumus inancgumus force-pushed the feat/gc-browser-processes branch from cb817d0 to ef87493 Compare November 12, 2021 13:24
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks and a question.

I was in the middle of reviewing it when you removed the psutil dependency :), but it's better if we can do this with the stdlib.

Some debug logging would be nice to know what's happening, and tests of course.

Also, why aren't we replacing the other direct uses of k6common.Throw()?

common/frame_session.go Outdated Show resolved Hide resolved
common/context.go Outdated Show resolved Hide resolved
common/helpers.go Outdated Show resolved Hide resolved
@inancgumus
Copy link
Member Author

inancgumus commented Nov 12, 2021

I was in the middle of reviewing it when you removed the psutil dependency :), but it's better if we can do this with the stdlib.

;)

Also, why aren't we replacing the other direct uses of k6common.Throw()?

PR description :) "We need to update k6common.Throw to our k6Throw for this to work stable. ... Automated tests are missing for now. I'm planning to do these in a separate PR."

@inancgumus inancgumus requested a review from imiric November 12, 2021 14:29
Copy link
Contributor

@imiric imiric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM, but I wasn't able to come up with a manual test for this scenario.

On main, stopping the test run with Ctrl+C or calling k6.fail() in the script properly kills the process and leaves no zombies behind. Panic issues also seem to get rid of the process. 😕 So I'm not sure about the exact scenario that reproduces this, but automated tests (E2E only I suppose) would help.

Since I don't see the code doing any harm, I'll merge this as is.

@imiric imiric merged commit 0334117 into main Nov 15, 2021
@imiric imiric deleted the feat/gc-browser-processes branch November 15, 2021 11:27
@inancgumus
Copy link
Member Author

inancgumus commented Nov 15, 2021

Would you please try running Tom’s earliest script (#49) within a for.. in bash (at least 10-50 times)? It happens almost every time for me on OSX. @imiric

@inancgumus inancgumus self-assigned this Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GC browser processes
3 participants