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

Fix hanging close browser cdp req #1442

Merged
merged 7 commits into from
Sep 25, 2024
Merged

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Sep 24, 2024

What?

We're putting a timeout on the CDP close request.

Why?

This is so that the connection is closed and we allow the iteration to end. Without this, the browser module can be left hanging indefinitely on the cdp send (well, waiting for the response from chromium) when actually chromium has already exited.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1440

@ankur22 ankur22 requested a review from inancgumus September 24, 2024 15:39
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

👍 Thanks! Before merging, should we wait for the k6 side of the fix?

common/browser.go Show resolved Hide resolved
chromium/browser_type.go Show resolved Hide resolved
@ankur22 ankur22 changed the title Fix/hanging close browser cdp req Fix hanging close browser cdp req Sep 24, 2024
@ankur22
Copy link
Collaborator Author

ankur22 commented Sep 25, 2024

should we wait for the k6 side of the fix?

Yep, good idea. I can then update k6 in this PR with the fix.

Done in 1095480

Use the existing background context instead of creating a new one.
Use the existing background context instead of creating a new one.
Since the context that is used is a essentially a background context,
we need to have a timeout in place. There is a chance that the browser
process has already exited but the connection thinks it is still alive.
By using the timeout we're ensuring that the iteration can end, which
allows for the events to be emitted by the k6 event system and so allow
k6 to exit in a timely manner.
Working with c.ctx will essentially never end since it is basically a
background context. Using the passed in context which has a timeout
will help ensure the send goroutine ends quickly.
@ankur22 ankur22 force-pushed the fix/hanging-close-browser-cdp-req branch from aa6a1c0 to b4b16ba Compare September 25, 2024 16:12
Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

Reapproving :)

@ankur22 ankur22 merged commit 1691ec7 into main Sep 25, 2024
23 checks passed
@ankur22 ankur22 deleted the fix/hanging-close-browser-cdp-req branch September 25, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants