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

Headed browser sessions aren't cleaned up #1268

Open
volkanunsal opened this issue Mar 11, 2025 · 12 comments
Open

Headed browser sessions aren't cleaned up #1268

volkanunsal opened this issue Mar 11, 2025 · 12 comments
Labels
help wanted Extra attention is needed

Comments

@volkanunsal
Copy link
Contributor

volkanunsal commented Mar 11, 2025

I'm noticing this issue with several browsers. To replicate:

const page = await host.browse(
  "https://microsoft.github.io/genaiscript/reference/scripts/browser/",
  {
    headless: false,
    browser: "firefox",
  }
);

Each time you run the script, it creates a new browser session.

What makes this worse is Chromium session cannot be quit with Cmd+Q. You have to Force Quit it. That's why I chose to use Firefox.

Image
Copy link

Issue Title: Headed browser sessions aren't cleaned up

Issue Body:
I'm noticing this issue with several browsers, specifically Firefox and Chromium. To replicate:

const page = await host.browse(
  "https://microsoft.github.io/genaiscript/reference/scripts/browser/",
  {
    headless: false,
    browser: "firefox",
  }
);

Each time you run the script, it creates a new browser session without cleaning up previous sessions. This makes it difficult to manage multiple browsing contexts and can lead to resource exhaustion.

For Firefox, quitting a browser session by using Cmd+Q does not properly close all associated processes, which necessitates Force Quitting.

Image

Please clarify if the issue is specific to Firefox or also affects Chromium. Additionally, could you provide information on how other browsers handle this scenario?

AI-generated content by issue-reviewer may be incorrect

@pelikhan
Copy link
Member

Try setting incognito to false to reuse the sessions.

@pelikhan
Copy link
Member

I will text this because there is code in place to close all pages, contexts and browsers.

@volkanunsal
Copy link
Contributor Author

Try setting incognito to false to reuse the sessions.

It doesn't seem to work for some reason.

@pelikhan
Copy link
Member

@volkanunsal what os are you using?

@pelikhan
Copy link
Member

This should fix it> #1274

@volkanunsal
Copy link
Contributor Author

Still seeing this issue with 1.114.4.

@pelikhan
Copy link
Member

What OS are you running?

@pelikhan
Copy link
Member

do you run the script through the cli or vscode?

@volkanunsal
Copy link
Contributor Author

I'm running on Mac. I ran it from VSCode.

@pelikhan
Copy link
Member

Ha I think I only run the cleaning out when I shut down the host.

Copy link

Summary

Users are encountering issues where browser sessions, specifically Firefox and Chromium, are not being properly cleaned up after each script execution in genaiscript. This leads to resource exhaustion and requires manual intervention on macOS, such as Force Quitting the browsers.

Current efforts to fix the issue include setting the incognito option to false, which has varying results. There is no consensus on a solution or a definitive cause of the problem. Additionally, there is uncertainty about how other browsers handle this scenario and whether the issue persists when running scripts through the CLI versus VSCode.

AI-generated content by issue-bot may be incorrect

@pelikhan pelikhan added the help wanted Extra attention is needed label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants