go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.43k stars 357 forks source link

segmentation violation after connection to browser is lost #1103

Open williamoliveira opened 3 months ago

williamoliveira commented 3 months ago

Rod Version: v0.116.2

I am connecting to an remote chrome via the ws endpoint. When it loses connection to the browser and I try to call a method without knowing it is disconnected, I get a panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x90 pc=0x105070180]

goroutine 1908 [running]:
github.com/go-rod/rod.(*Page).getJSCtxID(0x0?)
        /Users/williamoliveira/go/pkg/mod/github.com/go-rod/rod@v0.116.2/page_eval.go:325 +0x30
github.com/go-rod/rod.(*Page).evaluate(0x0, 0x140005af850)
        /Users/williamoliveira/go/pkg/mod/github.com/go-rod/rod@v0.116.2/page_eval.go:164 +0xc0
github.com/go-rod/rod.(*Page).Evaluate(0x0, 0x140005af850)
        /Users/williamoliveira/go/pkg/mod/github.com/go-rod/rod@v0.116.2/page_eval.go:129 +0x48
ysmood commented 1 month ago

If you don't use Must prefixed function, you won't get this panic:

https://go-rod.github.io/#/error-handling