Skip to content

Page.On('request') is racy #5341

@inancgumus

Description

@inancgumus

Brief summary

Running Page.On('request') (#4290) races with WebVital metrics.

k6 version

1.3.0

Steps to reproduce the problem

go run -race . run examples/browser/pageon-request.js

Expected behaviour

No panics.

Actual behaviour

==================
WARNING: DATA RACE, 1/1 VUs, 0 complete and 0 interrupted iterations
Write at 0x00c000372860 by main goroutine:----] 1 VUs  00m01.7s/10m0s  0/1 shared iters
  runtime.recvDirect()
      /usr/local/go/src/runtime/chan.go:405 +0x7c
  go.k6.io/k6/internal/cmd.(*cmdRun).run.func15()
      internal/cmd/run.go:386 +0x94
  runtime.deferreturn()
      /usr/local/go/src/runtime/panic.go:589 +0x5c
  go.k6.io/k6/internal/cmd.getCmdRun.func1()
     internal/cmd/run.go:552 +0x54
  go.k6.io/k6/internal/cmd.(*cmdRun).run()
     internal/cmd/run.go:105 +0x2dc
  go.k6.io/k6/internal/cmd.(*cmdRun).run-fm()
      <autogenerated>:1 +0x54
  github.com/spf13/cobra.(*Command).execute()
     vendor/github.com/spf13/cobra/command.go:856 +0x81c
  go.k6.io/k6/internal/cmd.(*rootCommand).persistentPreRunE-fm()
      <autogenerated>:1 +0x54
  github.com/spf13/cobra.(*Command).execute()
     vendor/github.com/spf13/cobra/command.go:835 +0x6f4
  github.com/spf13/cobra.(*Command).ExecuteC()
     vendor/github.com/spf13/cobra/command.go:974 +0x4c0
  github.com/spf13/cobra.(*Command).Execute()
     vendor/github.com/spf13/cobra/command.go:902 +0x178
  go.k6.io/k6/internal/cmd.(*rootCommand).execute()
     internal/cmd/root.go:144 +0x164
  go.k6.io/k6/internal/cmd.ExecuteWithGlobalState()
     internal/cmd/root.go:35 +0x12c
  go.k6.io/k6/cmd.Execute()
     cmd/execute.go:16 +0x34
  main.main()
     main.go:9 +0x20

Previous read at 0x00c000372860 by goroutine 113:
  runtime.chansend1()
      /usr/local/go/src/runtime/chan.go:162 +0x2c
  go.k6.io/k6/metrics.PushIfNotDone()
     metrics/sample.go:135 +0x4d4
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*FrameSession).parseAndEmitWebVitalMetric()
     internal/js/modules/k6/browser/common/frame_session.go:367 +0x358
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*FrameSession).onEventBindingCalled()
     internal/js/modules/k6/browser/common/frame_session.go:323 +0x18c
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*FrameSession).initEvents.func1()
     internal/js/modules/k6/browser/common/frame_session.go:311 +0x44c

Goroutine 113 (finished) created at:
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*FrameSession).initEvents()
     internal/js/modules/k6/browser/common/frame_session.go:241 +0x278
  go.k6.io/k6/internal/js/modules/k6/browser/common.NewFrameSession()
     internal/js/modules/k6/browser/common/frame_session.go:149 +0x694
  go.k6.io/k6/internal/js/modules/k6/browser/common.NewPage()
     internal/js/modules/k6/browser/common/page.go:318 +0x794
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*Browser).onAttachedToTarget()
     internal/js/modules/k6/browser/common/browser.go:320 +0x3b8
  go.k6.io/k6/internal/js/modules/k6/browser/common.(*Browser).initEvents.func1()
     internal/js/modules/k6/browser/common/browser.go:237 +0x2dc
==================

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions