-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onTTFB reported without navigation entry after BFCache restore #313
Comments
It should report as 0 in this case: Lines 95 to 102 in 0a87ab0
I confirmed it does on web.dev: There is an issue (see #275) where TTFB is sometimes not reported when the original nav (that the bfcache restore is restoring too) was the result of a cross origin redirect. In that case we choose not to report a TTFB for the bfcache restore too so it could be you're hitting this issue, in which case you should account for that with optional chaining: metric.entries[0]?.requestStart Or if you want to report 0 (we choose not to): metric.entries[0]?.requestStart || 0 |
Thank you! So complete example, if we don't need to report
|
Sorry, understand, the main decision is to not report, or report |
Ah yes. In the case of bfcache, as the value is dummied, there is no "entries". But I don't understand why you are not reporting metric.value every time anyway? Why are you removing the |
Good question) @Zizzamia what do you think about simplify TTFB report in perfume.js? Or there is some important reason behind this decision? |
Looks like in |
Ah there's so many definitions of TTFB 😁 But for bfcache restores won't they ALL be 0 anyway? So I would guess your decision is whether to just report 0 if it's not defined. For web-vitals we decided NOT to do that when the original TTFB was 0 - technically this should never happen, so indicates something went wrong (e.g. it was removed for privacy reasons) so rather than report 0, we elected to just not report it (for the original nav, and for bfcache restores) to avoid skewing the numbers. There's argument to still report it for bfcache restores (as it is 0), but we elected not to for consistency. Either way, I think this is all due to how you're implementing it slightly differently than web-vitals.js (in not using |
Thanks for the complete answers, yes looks like everything is fine on the |
We use this reciepe - https://github.com/GoogleChrome/web-vitals#onttfb
When page was restored from BFCache,
metric.entries
array is empty andmetric.entries[0].requestStart
will throw error.What is the correct way to collect TTFB in this case?
Maybe any rework needed in this https://github.com/GoogleChrome/web-vitals/blob/main/src/onTTFB.ts#L95 callback?
The text was updated successfully, but these errors were encountered: