Skip to content
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

After a panic() the terminal input does not show #1127

Closed
delightfulagony opened this issue Sep 2, 2024 · 3 comments
Closed

After a panic() the terminal input does not show #1127

delightfulagony opened this issue Sep 2, 2024 · 3 comments

Comments

@delightfulagony
Copy link

delightfulagony commented Sep 2, 2024

Describe the bug
After a program panic, the terminal input does not work properly.

Setup
Please complete the following information along with version numbers, if applicable.

  • Ubuntu 22.04.4 (WSL2)
  • BASH 5.1.16(1)-release
  • Microsoft Terminal 1.20.11781.0
  • tmux 3.2a
  • bubbletea v1.1.0

To Reproduce
Steps to reproduce the behavior:

  1. Execute the provided sample program.
  2. Attempt to write to terminal after the panic, it will not display anything.

Source Code

package main

import (
	"fmt"
	"os"
	"time"

	tea "github.com/charmbracelet/bubbletea"
)

type model struct{}

func (m model) Init() tea.Cmd {
	return nil
}

func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	return m, nil
}

func (m model) View() string {
	return "I will panic"
}

func main() {

	go func() {
		time.Sleep(2 * time.Second)
		panic("")
	}()

	m := model{}

	if _, err := tea.NewProgram(m).Run(); err != nil {
		fmt.Println("Uh oh, we encountered an error:", err)
		os.Exit(1)
	}
}

Expected behavior
I expected control to be given back to the terminal emulator and for it to be working normally.

Screenshots
image
After a panic the terminal behavior is broken, running reset fixes it.

Additional context
Add any other context about the problem here.

@blvrd
Copy link

blvrd commented Sep 10, 2024

I'm also running into this. #846 may fix the issue, but it's been open for a while with no activity.

@meowgorithm
Copy link
Member

Thanks for the report! So I can reproduce this, however it's somewhat of an interesting case because the panic is occurring independent of Bubble Tea.

#846 was designed to solve a separate issue, but it may be what we want here. We'll look into this.

@blvrd
Copy link

blvrd commented Sep 10, 2024

Ah, you're right, this panic isn't coming from inside a tea.Cmd. Sorry for confusing the situation!

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

No branches or pull requests

3 participants