When running @cloudflare/speedtest in the browser, i receive this warning:
TypeError: Cannot read properties of undefined (reading 'transferSize')
This happens intermittently:
- On first page load,
- On refresh it often works fine.
Looking at the Performance API, the transferSize property is not always guaranteed:
- For cross-origin requests without proper Timing-Allow-Origin headers
- When resources are served from cache
Because the library directly assumes transferSize exists, it sometimes throws.
Steps to reproduce
- Run @cloudflare/speedtest in a React/Next/Vite app
- Observe console logs on first page load
- Sometimes error appears, sometimes not
- Refresh the page → the error disappears