charmbracelet / charmbracelet/bubbletea

Data race in bubbletea.NewProgram.WithColorCache.func1()

Open
#910 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Data race when runnig test code with `-race`

**Trace**

```
WARNING: DATA RACE
Write at 0x00c00013358a by goroutine 342:
github.com/charmbracelet/bubbletea.NewProgram.WithColorCache.func1()
/tmp/go-path/pkg/mod/github.com/muesli/termenv@v0.15.2/output.go:107 +0x37
github.com/charmbracelet/bubbletea.NewProgram()
/tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:209 +0x353
github.com/ubuntu/authd/pam/internal/adapter.TestGdmModel.func23()
/home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:1279 +0xb44
testing.tRunner()
/snap/go/10489/src/testing/testing.go:1595 +0x261
testing.(*T).Run.func1()
/snap/go/10489/src/testing/testing.go:1648 +0x44

Previous read at 0x00c000133588 by goroutine 334:
github.com/charmbracelet/bubbletea.(*Program).checkResize()
/tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tty.go:99 +0x67
github.com/charmbracelet/bubbletea.(*Program).handleResize.func1()
/tmp/go-path/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:259 +0x33

Goroutine 342 (running) created at:
testing.(*T).Run()
/snap/go/10489/src/testing/testing.go:1648 +0x845
github.com/ubuntu/authd/pam/internal/adapter.TestGdmModel()
/home/marco/Dev/authd/pam/internal/adapter/gdmmodel_test.go:1235 +0x5c08
testing.tRunner()
/snap/go/10489/src/testing/testing.go:1595 +0x261
testing.(*T).Run.func1()
/snap/go/10489/src/testing/testing.go:1648 +0x44

```

Code here isn't doing anything just calling into bubbletea code, this can be workarounded by using `tea.WithOutput(os.Stdout)` so that `termenv.WithColorCache` is not called.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.