Skip to content

Commit 2f0630d

Browse files
committed
Add FID deprecation warn when first browser start
When the first browser instance (chrome) is started or connected to, we want to log a warning that FID has been deprecated and INP is the web vital to work with now.
1 parent ef40a4b commit 2f0630d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/js/modules/k6/browser/browser/registry.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ type browserRegistry struct {
184184

185185
type browserBuildFunc func(ctx, vuCtx context.Context) (*common.Browser, error)
186186

187+
var fidDeprecationWarningOnce sync.Once
188+
187189
// newBrowserRegistry should only take a background context, not a context from
188190
// k6 (i.e. vu). The reason for this is that we want to control the chromium
189191
// lifecycle with the k6 event system.
@@ -208,6 +210,10 @@ func newBrowserRegistry(
208210
wsURL, isRemoteBrowser = remote.isRemoteBrowser()
209211
)
210212

213+
fidDeprecationWarningOnce.Do(func() {
214+
vu.State().Logger.Warnf("FID has been deprecated and superseded by INP -- https://web.dev/blog/fid")
215+
})
216+
211217
if isRemoteBrowser {
212218
b, err = bt.Connect(ctx, vuCtx, wsURL)
213219
if err != nil {

internal/js/modules/k6/browser/common/frame_session.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import (
3636

3737
const utilityWorldName = "__k6_browser_utility_world__"
3838

39-
var fidDeprecationWarningOnce sync.Once
40-
4139
// CPUProfile is used in throttleCPU.
4240
type CPUProfile struct {
4341
// rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
@@ -347,10 +345,6 @@ func (fs *FrameSession) parseAndEmitWebVitalMetric(object string) error {
347345
return fmt.Errorf("json couldn't be parsed: %w", err)
348346
}
349347

350-
fidDeprecationWarningOnce.Do(func() {
351-
fs.logger.Warnf("FrameSession:parseAndEmitWebVitalMetric", "FID has been deprecated and superseded by INP -- https://web.dev/blog/fid")
352-
})
353-
354348
metric, ok := fs.k6Metrics.WebVitals[wv.Name]
355349
if !ok {
356350
return fmt.Errorf("metric not registered %q", wv.Name)

0 commit comments

Comments
 (0)