playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.

Home Page:https://playwright-community.github.io/playwright-go/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

browser close call sometimes hang

tejaskumark opened this issue · comments

Hello Experts,

Currently I am using playwright-go version 0.3500.0, and sometimes I have seen that for no reason browser close call is hanging.
I am wondering if there is any way to timeout in such situation or any way to catch such things and move on?

  • Also needs some best practice advice on my use case,
  • In my application, I need to keep 10-15 different browser tab open for long period of time, so what should be the recommended way here? I should only create one playwright instance for all browser or create multiple per browser or may be load balance between multiple playwright instance?
    Thank you.

For your application, if different browser tabs do not need to share cookies and storage states, you can use multiple BrowserContexts.

And since playwright-go still v0.x.x, it is recommended to always upgrade to the latest version.
If it doesn't help, please provide code or steps that can reproduce the issue.

Thanks @canstand for reply.

Actually this is happening on very rare occasion, also once it hangs I don't get any logs and only thing I do is kill the process and start it again. I have to think of something which can provide me some logs.

For now, is there any timeout or such things we can use for such cases?

Most methods have timeouts. According to my experience, when using methods with On prefix such as Page.OnRoute, BrowserContext.OnResponse, it may hang in rare cases.

If you can run in debug mode in vscode, you can pause execution if a hang occurs. Then look at the call stack to investigate where it hangs.

Thanks @canstand. But looks like I am not able to reproduce it since long. For now will close this case and will reopen if I get into that situation again.
Thanks again for all the help.