Skip to content

fix: prevent data race with cursedRenderer.onMouse#1691

Open
lrstanley wants to merge 1 commit intocharmbracelet:mainfrom
lrstanley:feature/fix-onmouse-datarace
Open

fix: prevent data race with cursedRenderer.onMouse#1691
lrstanley wants to merge 1 commit intocharmbracelet:mainfrom
lrstanley:feature/fix-onmouse-datarace

Conversation

@lrstanley
Copy link
Copy Markdown
Contributor

@lrstanley lrstanley commented May 4, 2026

Changes in this PR

Fixes a data race in the cursed renderers OnMouse handler. Opted to capture just the handler, rather than duplicating the reference to keep the intent clear.

  • closes bug: data race between received mouse events and using cursed renderer #1690
  • Added -race, -count, and -cpu to taskfile. Ideally, more people should run with these tests to help cover more data race testing, flaky tests, as well as tests which may not actually surface issues unless the CPU > 1, and vice versa.
  • Added t.Parallel() (to root or within t.Run()) to all viable tests that don't do any global state or similar mutations.
  • Fixed examples/go.mod & examples/go.sum not being in sync, though unrelated to my change.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.50%. Comparing base (640d879) to head (04ceac4).

Files with missing lines Patch % Lines
cursed_renderer.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1691      +/-   ##
==========================================
+ Coverage   55.64%   56.50%   +0.85%     
==========================================
  Files          25       25              
  Lines        1310     1315       +5     
==========================================
+ Hits          729      743      +14     
+ Misses        491      482       -9     
  Partials       90       90              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lrstanley lrstanley force-pushed the feature/fix-onmouse-datarace branch from c100786 to f5c8e7a Compare May 4, 2026 23:57
- closes charmbracelet#1690
- adds `-race`, `-count`, and `-cpu`
- make all viable tests parallel

Signed-off-by: Liam Stanley <liam@liam.sh>
@lrstanley lrstanley force-pushed the feature/fix-onmouse-datarace branch from f5c8e7a to 04ceac4 Compare May 4, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: data race between received mouse events and using cursed renderer

1 participant