web.dev consistently errors on Network.getResponseBody for main content
See original GitHub issue- run
node lighthouse-cli/index.js https://web.dev --only-categories best-practices --view
- get
Properly defines charset – Error!
(also happens in DevTools and PSI)
The error is
Required MainDocumentContent gatherer encountered an error: Protocol error (Network.getResponseBody): No resource with given identifier found
and occurs here in driver
when called from main-document-content
.
It seems unusual that the main document content wouldn’t be available for the backend. @robdodson does mention some unusual things done with the service worker and “an app shell that pulls in an index.json of the page content when you go to other pages. We essentially replace main content area with this new content” that could be causing trouble (maybe the request really didn’t have any content?).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Chrome Extension: "No resource with given identifier found ...
It was because the website sends many responses, and this code will see another request other than I want, then detach the debugger...
Read more >Network.getResponseBody - Vanilla Protocol Viewer
Fired when WebSocket message error occurs. Parameters. errorMessage. stringWebSocket error message. requestId. Network.RequestIdRequest identifier. timestamp.
Read more >Network domain - Chrome DevTools Protocol - GitHub Pages
Chrome DevTools Protocol - version tot - Network domain. ... Identifier of the network request to get content for. ... Always set to...
Read more >HTTP Messages - MDN Web Docs - Mozilla
Web developers, or webmasters, rarely craft these textual HTTP messages ... data associated with the request (like content of an HTML form), ...
Read more >Fetch - The Modern JavaScript Tutorial
Fetch. JavaScript can send network requests to the server and load new information whenever it's needed. For example, we ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah thanks @thepassle that helps a lot! I think this is happening because Chrome might only keep the network resources from the current page load in the memory cache which is what Lighthouse relies on to get the response body of the root document. We can do a bit more digging but this is a great head start 👍
related #8984 #11027
We debugged a little bit more, we use a code snippet to reload the page when a new service worker has taken over:
❌ With that piece of code:
✅ Without that piece of code:
It seems that the reload is causing the best practices to error, hope that helps 🙂
EDIT:
In case anybody wants to workaround this, this seems to fix it. Also skips an unnecessary reload the first time a user visits your app (even though its so fast you might not have noticed)