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

Playwright-go silently hanging at random points #390

Open
achsal2 opened this issue Nov 21, 2023 · 4 comments
Open

Playwright-go silently hanging at random points #390

achsal2 opened this issue Nov 21, 2023 · 4 comments

Comments

@achsal2
Copy link

achsal2 commented Nov 21, 2023

i saw a similar issue on this but it was said that its been fixed yet i still face this issue where sometimes the browser just hangs and becomes unresponsive to any calls at random points of my scraper after a while, it doesnt crash or disconnect, just goes unresponsive, it's a hard issue to reproduce because it happens randomly and i tested every single action to make sure where the specific call that causes this can be but its random, i have 5 workers each processing some jobs that call newContext and newPage and execute the process then clean up by closing the page and context, on playwright's issues i heard not using the same context over and over is good to avoid this but could this be whats causing it ?

@canstand
Copy link
Collaborator

try run in debug mode in vscode, and pause the execution when a hang occurs, then check the call stack of the racing goroutine

@achsal2
Copy link
Author

achsal2 commented Nov 21, 2023

its very hard for me to debug on vscode since this happens one after a while of processing a large number of data , but i did notice that when i switch off a handler that deals with iframes i have yet to see it freeze then, and i also remember being on go-rod and the browser would crash everytime it needed to work with an iframe and it wasnt headless so im tempted to say its relating to working with elements inside iframes. the go-rod developers said its potentially a bug with chrome devtools is there a know issue with iframes in playwright as well ?

i know its hard to work with a bug that cant be consistantly reproduced so thanks for the help im trying to figure out how i can reproduce it

@achsal2
Copy link
Author

achsal2 commented Nov 28, 2023

for anyone facing the same issue, its due to the use of .Lock and .Unlock all over the playwright library which creates deadlocks , in my case it was a race condition between the router handling or waiting for a request to finish (due to route.Fetch probably) and a call to page.Close(), the only way i got it to work is by removing playwright's p.Lock() and p.Unlock() and adding my own graceful shutdown logic for the router, aborting the requests before calling page.Close()

im not aware if there's a workaround to this without modifying playwright so if you do let me know

@canstand
Copy link
Collaborator

The latest version should have some improvements. But it is known that firefox may still have problems.

#362 (comment)

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

No branches or pull requests

2 participants