rod: Cannot hijack requests cached by the service worker.
Rod Version: v0.82.1
Steps to reproduce
I tried to hijack the request from the website with the service worker, like https://twitter.com/home.
So that I can retrieve the JSON response from the request which is stable than retrieving from HTML.
Somehow, the requests are all missing from the hijack router.
The full sample code.
func main() {
l := launcher.New().
Headless(false).
Leakless(false)
browser := rod.New().
Timeout(time.Second * 15).
ControlURL(l.MustLaunch()).
Trace(true).
MustConnect()
router := browser.HijackRequests()
router.MustAdd("*", func(ctx *rod.Hijack) {
fmt.Println("Hijacked URL:", ctx.Request.URL())
ctx.MustLoadResponse()
})
go router.Run()
page := browser.MustPage("https://twitter.com/home")
wait := page.MustWaitRequestIdle()
wait()
}
Expected behavior
All requests should be hijacked like normal website. But somehow, they are not.
If we directly visited a website, we would see several requests in the network tab, while they are not in the actual result.

Actual result
Hijacked URL: https://abs.twimg.com/responsive-web/client-web/polyfills.4d8d59c5.js
Hijacked URL: https://abs.twimg.com/responsive-web/client-web/vendors~main.f7f618b5.js
Hijacked URL: https://abs.twimg.com/responsive-web/client-web/main.f51fb665.js
Hijacked URL: https://abs.twimg.com/responsive-web/client-web/i18n/en.fa8270e5.js
I guess it is because the web with service work cannot be hijacked, as I found in the puppeteer issue https://github.com/puppeteer/puppeteer/issues/4041#issuecomment-469496322
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15
https://en.wikipedia.org/wiki/Environment_variable
https://pkg.go.dev/github.com/go-rod/rod@v0.85.9/lib/defaults