Skip to content

race condition in Eventually #835

@amir-arad

Description

@amir-arad

I've used a tightly timed 'Eventually' in my test:
assert.Eventually(t, func() bool { ... }, time.Millisecond*100, time.Millisecond)
ran it with -race -count=1000 and i got:

==================
WARNING: DATA RACE
Write at 0x00c0000ba5b0 by goroutine 34:
  runtime.closechan()
      /.../go/go1.12.9/src/runtime/chan.go:334 +0x0
  github.com/stretchr/testify/assert.Eventually()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/testify@v1.4.0/assert/assertions.go:1490 +0x29e
  github.com/stretchr/testify/require.Eventually()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/testify@v1.4.0/require/require.go:278 +0xaf
  command-line-arguments_test.TestPeriodicalTriggerStopWorksWhenContextIsCancelled.func1()
    ...

Previous read at 0x00c0000ba5b0 by goroutine 62:
  runtime.chansend()
      /.../go/go1.12.9/src/runtime/chan.go:142 +0x0
  github.com/stretchr/testify/assert.Eventually.func1()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/testify@v1.4.0/assert/assertions.go:1494 +0x54

Metadata

Metadata

Assignees

No one assigned

    Labels

    assert.EventuallyAbout assert.Eventually/EventuallyWithTbugpkg-assertChange related to package testify/assert

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions