ref(browser): Replace vendored web-vitals with web-vitals@6 dependency - #23070
Open
logaretm wants to merge 3 commits into
Open
ref(browser): Replace vendored web-vitals with web-vitals@6 dependency#23070logaretm wants to merge 3 commits into
logaretm wants to merge 3 commits into
Conversation
logaretm
force-pushed
the
awad/webvitals-dep-only
branch
from
August 5, 2026 16:47
d23f63e to
64997f2
Compare
Contributor
size-limit report 📦
|
logaretm
force-pushed
the
awad/webvitals-dep-only
branch
4 times, most recently
from
August 5, 2026 19:16
43daa35 to
b2a21b4
Compare
Upstream web-vitals v6 covers the metrics we vendored, so consume it as a dependency instead of maintaining a ~1.9k-line in-tree copy. instrument.ts imports the metric functions from the package and observes performance entries with a local PerformanceObserver; the handful of generic browser helpers still needed (getNavigationEntry, getVisibilityWatcher, whenIdleOrHidden, etc.) move to metrics/web-vitals-helpers, and the rest of the vendored code is deleted. No behavior change: browser-utils unit tests and the browser-integration web-vitals suites (LCP/CLS/INP/FCP/TTFB + streamed spans) all pass.
logaretm
force-pushed
the
awad/webvitals-dep-only
branch
from
August 5, 2026 19:44
b2a21b4 to
a786f2c
Compare
logaretm
marked this pull request as ready for review
August 5, 2026 20:03
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a786f2c. Configure here.
The vendored `observe` helper wrapped PerformanceObserver callbacks in a microtask to work around a Safari bug where the callback fires synchronously during `observe()` instead of in a separate task (GoogleChrome/web-vitals#277). The local `instrumentPerformanceObserver` dropped that defer, so paint/longtask/event/ element handlers could run synchronously at init on affected Safari versions. Upstream web-vitals@6 still ships this defer, so restore it here to match.
`instrumentInp` returns the `StopListening` cleanup from `onINP`, matching its `instrumentCls`/`instrumentLcp`/`instrumentTtfb` siblings and the `addMetricObserver` `instrumentFn` parameter, but was typed `void`. That silently discarded the cleanup so a future `stopOnCallback` on INP would no-op.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Replaces the vendored web-vitals fork with
web-vitals@6as a dependency.No behavior change. browser-utils unit tests and the browser-integration web-vitals suites (LCP/CLS/INP/FCP/TTFB + streamed spans) pass, plus we still gate the bfcache web vitals from being sent, so identical behavior as of today.
A couple of concerns we discussed: