playwright-community / playwright-go

Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.
https://playwright-community.github.io/playwright-go/
MIT License
1.94k stars 144 forks source link

Hangs on Content() #415

Open reginaldl opened 4 months ago

reginaldl commented 4 months ago

Hi,

I'm experiencing what appears to be a deadlock when calling page.Content(). I'm crawling multiple pages in parallel using different browser contexts. It works great most of the time, but it will eventually hang after some iterations.

I've been doing some debugging, here is the stack trace where it hangs:

goroutine 301671 [select]:
github.com/playwright-community/playwright-go.(*protocolCallback).GetResult(...)
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/connection.go:379
github.com/playwright-community/playwright-go.(*channel).innerSend(0x14008492af0, {0x10486880d, 0x7}, 0x0, {0x0?, 0x14000a0ea68?, 0x14006eaa370?})
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/channel.go:34 +0xd8
github.com/playwright-community/playwright-go.(*channel).Send.func1()
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/channel.go:18 +0x38
github.com/playwright-community/playwright-go.(*connection).WrapAPICall(0x0?, 0x14007d15c40, 0x0?)
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/connection.go:163 +0xb4
github.com/playwright-community/playwright-go.(*channel).Send(0x0?, {0x10486880d?, 0x10441c6d0?}, {0x0?, 0x10441c730?, 0x14005453bc0?})
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/channel.go:17 +0x64
github.com/playwright-community/playwright-go.(*frameImpl).Content(0x14007d15d18?)
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/frame.go:72 +0x38
github.com/playwright-community/playwright-go.(*pageImpl).Content(0x14006eaa250?)
        /Users/reginald/go/pkg/mod/github.com/playwright-community/playwright-go@v0.4101.0/page.go:239 +0x28

In this specific case, it hung for 17s. I'd appreciate some help debugging this.

Does this mean that the underlying driver died somehow? Could we get stuck if the page is reloading or navigating? I'm running with DEBUGP now, will update if anything comes up.

reginaldl commented 4 months ago

So I'm seeing this being sent:

ESC[32mSEND>ESC[0m
{"guid":"frame@37d9349a3f09fa710a337896a6e6dc94","id":356473,"metadata":{"apiName":"SerializeCallStack","isInternal":false,"location":{"file":"connection.go","line":162},"wallTime":326321000},"method":"content",
"params":{}}

Unfortunately, no response to "id": 356473. Playwright is definitely there as I see requests from other contexts...

canstand commented 4 months ago

It's more like an upstream issue. Most timeouts are controlled by the server side (upstream). We need a way to reproduce it before we can investigate it.

gokaybiz commented 3 months ago

So I'm seeing this being sent:

ESC[32mSEND>ESC[0m
{"guid":"frame@37d9349a3f09fa710a337896a6e6dc94","id":356473,"metadata":{"apiName":"SerializeCallStack","isInternal":false,"location":{"file":"connection.go","line":162},"wallTime":326321000},"method":"content",
"params":{}}

Unfortunately, no response to "id": 356473. Playwright is definitely there as I see requests from other contexts...

Hi, is it a firefox issue, am i right?