-
Notifications
You must be signed in to change notification settings - Fork 840
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
Recover panics from within cmds goroutines #234
Comments
Thanks for reporting @brooks-connor-a, ran into this also. (Firing up background Tor process, then panic, then it isn't cleaned up) |
I took a look at this, it seems like the best way to solve was to recover the panic and write to the |
Hi! Just a note that this is now fixed and available in Bubble Tea v1.1.1. You can use p := tea.NewProgram(model{})
go func() {
time.Sleep(3 * time.Second)
defer p.Kill()
panic("Oh no!")
}()
if _, err := p.Run() {
log.Fatal(err)
} |
Panics are handled by recovering the panic and gracefully tearing down the Program. However goroutines started within the Program are outside the scope of the recover, and as such can end in the program terminating without properly tearing down. This can result in the terminal getting stuck in a non-interactive state until it is reset.
Here's a minimal reproduction:
The text was updated successfully, but these errors were encountered: