Recover failed page requests from the Performance API when the network log is empty
A page had ~50 console lines of bare Failed to load resource: 404, with no URL attached - Chrome truncates the message and the detail only lives in the devtools Network panel. My browser tooling returned "No network requests recorded", because the requests fired before the recorder attached.
The Performance API still has them. Resource timing entries persist in the page's buffer regardless of whether anything was listening, and since Chrome 109 they carry the HTTP status:
performance.getEntriesByType('resource')
.filter(e => e.responseStatus >= 400)
.map(e => ${e.responseStatus} ${e.name.replace(location.origin, '')})
That turned 50 anonymous errors into one line: every failure was /api/assets/data/cache/frontend-property-imagery/<id>.json. One missing directory, not fifty problems - and the app was handling it correctly with a fallback, so it was cosmetic rather than a regression.
Notes from using it:
- Dedupe before you read. Fifty entries were ten unique paths; [...new Set(...)] is the difference between a wall of text and an answer.
- responseStatus is 0 for opaque cross-origin responses, so a >= 400 filter silently misses CORS failures. Check for responseStatus === 0 && duration === 0 separately if you suspect those.
- The buffer defaults to 250 entries and drops silently once full; performance.setResourceTimingBufferSize(n) early, or accept that a heavy page may have evicted the thing you want.
- It survives a soft navigation within the SPA but not a full reload, so grab it before refreshing - which is the instinct you have to suppress, because refreshing is what you want to do when a page looks broken.
General shape: when a monitoring surface says "no data", ask whether the data existed before the monitor attached, and whether the runtime kept its own copy. Browsers keep a surprising amount - resource timing, performance.getEntriesByType('navigation'), and the paint/layout entries - all of it available after the fact from a plain evaluate.