We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Environments
Bug description The provided example leaves behind a defunct chromium process.
To Reproduce This code reproduces the problem:
package main import ( "fmt" "net/http" "github.com/playwright-community/playwright-go" ) func pingHandler(w http.ResponseWriter, r *http.Request) { pw, err := playwright.Run() if err != nil { panic(err) } defer func() { err = pw.Stop() if err != nil { panic(err) } }() browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ Args: []string{ "--allow-running-insecure-content", }, Headless: playwright.Bool(true), }) if err != nil { panic(err) } defer func() { err = browser.Close() if err != nil { panic(err) } }() baseUrl := "https://playwright.dev/" permissions := []string{"clipboard-read", "clipboard-write", "storage-access"} page, err := browser.NewPage(playwright.BrowserNewPageOptions{ BaseURL: playwright.String(baseUrl), BypassCSP: playwright.Bool(true), JavaScriptEnabled: playwright.Bool(true), Permissions: permissions, Viewport: &playwright.Size{ Width: 1240, Height: 800, }, }) if err != nil { panic(err) } defer func() { err = page.Close() if err != nil { panic(err) } }() webErrors := make([]string, 0) page.OnPageError(func(e error) { webErrors = append(webErrors, e.Error()) }) page.OnConsole(func(e playwright.ConsoleMessage) { webErrors = append(webErrors, e.Text()) }) _, err = page.Goto(baseUrl, playwright.PageGotoOptions{ WaitUntil: playwright.WaitUntilStateNetworkidle, }) if err != nil { panic(err) } for _, webError := range webErrors { fmt.Printf("%s\n", webError) } _, err = fmt.Fprintf(w, "pong") if err != nil { panic(err) } } func main() { err := playwright.Install(&playwright.RunOptions{ Browsers: []string{"chromium"}, }) if err != nil { panic(err) } http.HandleFunc("/ping", pingHandler) fmt.Println("Starting server at :8080") if err := http.ListenAndServe(":8080", nil); err != nil { fmt.Printf("Error starting server: %s\n", err) } }
$ git clone https://github.com/morten-holm/playwright-demo.git $ docker build -t playwright-demo . $ docker run --rm -p 8080:8080 playwright-demo $ http localhost:8080/ping
After this running 'ps xua' will give a result like this:
# ps xua | grep chrome root 128 0.0 0.0 0 0 ? Z 06:16 0:00 [chrome] <defunct> root 129 0.0 0.0 0 0 ? Z 06:16 0:00 [chrome] <defunct> root 198 0.0 0.0 3124 1384 pts/0 S+ 06:16 0:00 grep chrome
The text was updated successfully, but these errors were encountered:
You just need to start a browser and close it when the program exits. Just create a new BrowserContext for each request.
BrowserContext
Sorry, something went wrong.
No branches or pull requests
Environments
Bug description
The provided example leaves behind a defunct chromium process.
To Reproduce
This code reproduces the problem:
$ git clone https://github.com/morten-holm/playwright-demo.git $ docker build -t playwright-demo . $ docker run --rm -p 8080:8080 playwright-demo $ http localhost:8080/ping
After this running 'ps xua' will give a result like this:
The text was updated successfully, but these errors were encountered: