Skip to content

(v1-1/3) tea.go: fix deadlock on context cancellation #1372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

desertwitch
Copy link

@desertwitch desertwitch commented Mar 25, 2025

fixes #1370
closes #1292

context cancellation causes immediate exit of channel receiving routine handleCommands
select statement wrap prevents deadlocks on eventLoop sends to stale channel and ensures routine exit

@aymanbagabas
Copy link
Member

Great find @desertwitch! Could you add a test case covering this?

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@6a1ebaa). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1372   +/-   ##
=======================================
  Coverage        ?   69.25%           
=======================================
  Files           ?       17           
  Lines           ?     1698           
  Branches        ?        0           
=======================================
  Hits            ?     1176           
  Misses          ?      474           
  Partials        ?       48           

☔ 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.

@desertwitch
Copy link
Author

desertwitch commented Mar 26, 2025

Great find @desertwitch! Could you add a test case covering this?

Sure - I've added the tests, also squashed and reworded my commits to follow the message convention. 😉

P.S. This resolves the symptom of a program getting stuck on context cancellation from "within" (a model's methods).

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thank you!

@caarlos0
Copy link
Member

closes #1292

@caarlos0 caarlos0 added the bug Something isn't working label Mar 26, 2025
@desertwitch desertwitch changed the title tea.go: fix deadlock on context cancellation (1/3) tea.go: fix deadlock on context cancellation Mar 28, 2025
@bashbunni bashbunni added this to the v2.0.0 milestone Apr 7, 2025
@desertwitch desertwitch changed the title (1/3) tea.go: fix deadlock on context cancellation (v1-1/3) tea.go: fix deadlock on context cancellation Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deadlock on context cancellation (inside eventLoop)
4 participants