Closed nordfjord closed 2 months ago
We've had another report of this too and are investigating.
Can you confirm:
Version is web-vitals@4.0.1
.
here's the report on browser stats
And all those browser are seeing this issue?
yes! This is the spread that's reporting this error specifically
How common is this do you know?
And would you be able to run a custom build to help us track it down?
How common is this do you know?
And would you be able to run a custom build to help us track it down?
About 5% of our users seem to experience it, and yes, I can run a custom build
We released a debug version here: https://unpkg.com/web-vitals@4.2.0-debug.0/dist/web-vitals.attribution.js
You should be able to install using npm install web-vitals@debug
We basically added the below code. It will still cause an error (but this time by explicitly raising an exception) as we haven't fixed the issue, but we're hoping it will give us more information in that exception when that happens.
There is also a chance this issue is fixed as we refactored some of this code. So if you do not see errors with this code then you can try the latest production version (4.1.1
) and see if that's the same.
Let us know how you get on and if you could share some error messages we can look further.
if (!group) {
// @ts-ignore
const obj = {
reportTime: performance.now(),
navigationType: metric.navigationType,
entries: metric.entries.map((e) => {
return Object.assign({interactionId: e.interactionId}, e.toJSON());
}),
value: metric.value,
delta: metric.delta,
};
// This should never happen, so throw an error to figure out why.
throw new Error(`Missing group: ${JSON.stringify(obj)}`);
}
There is also a chance this issue is fixed as we refactored some of this code. So if you do not see errors with this code then you can try the latest production version (
4.1.1
) and see if that's the same.
Quick clarification, the most recent changes from #495 have not yet been released into any stable version, but we think there's a chance they might fix (or at least improve) the issue. So if you try out the debug
build and stop seeing errors, we'll make sure to publish a version 4.2.0
ASAP with that fix.
Thanks! I've submitted the PR on my side and expect it to go out in the morning
Any update @nordfjord ? did the patch go out and are you still seeing the errors?
@tunetheweb, patch went out yesterday and I've not seen the error yet, keeping an eye out and will let you know how if that changes
Happy to report I've not seen this error crop up in the last 2 days. So I think it's safe to mark as fixed and cut a release for 4.2.0!
FYI we released 4.2.0 yesterday. Thanks for your help with testing!
We're getting an error in production because
group
is undefinedI took a quick look at the code and it seems like it's related to this piece of code https://github.com/GoogleChrome/web-vitals/blob/9ef33074f7a5c03f687f5685a57b1fa998d540e5/src/attribution/onINP.ts#L245
Map#get
returnsT | undefined
and it's being marked as non-nullable in the code. In production we're definitely hitting the case of it returning undefined. Maybe a proper null check is in order?