sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.
https://sanic.dev
MIT License
18.03k stars 1.55k forks source link

CLI: Terminal becomes no-echo if not entering REPL mode or exiting without Ctrl+D #2900

Open Huy-Ngo opened 9 months ago

Huy-Ngo commented 9 months ago

Is there an existing issue for this?

Describe the bug

When running sanic in development mode without turning off REPL, that is, sanic --dev server, if I don't enter the REPL mode before exiting, the terminal becomes no-echo (what I type does not shows on screen). (This can be turned off by running stty echo, but it shouldn't happen in the first place.)

Steps to reproduce:

  1. Run sanic in development mode without REPL disabled: sanic --dev server
  2. Do one of the following:
    • Exit the server immediately with Ctrl+C
    • Enter the REPL, then exit with Ctrl+C
    • Enter the REPL, then exit with exit()

The terminal does not becomes no-echo if I enter the REPL, then exit with Ctrl+D

Expected Behavior

The terminal is not in no-echo mode.

How do you run Sanic?

Sanic CLI

Operating System

Linux

Sanic Version

23.12.0

Huy-Ngo commented 9 months ago

Maybe this have something to do with input() at sanic/cli/console.py:220 being interrupted not handled correctly?

ahopkins commented 6 months ago

What version of Linux are you on? This is not my experience at all using Arch.

Huy-Ngo commented 6 months ago

I'm using Alpine Linux. Using its own libc and coreutils, I suppose it cause this issue.

Huy-Ngo commented 3 weeks ago

I've just tried this again with latest PyPI (Arch's packaged sanic doesn't have REPL) on Archlinux on WSL and has the same problem. Windows itself does not have this issue (perhaps it doesn't even have no-echo mode in the first place? I'm not familiar with Windows).

I also find that Enter key sends ^M and backspace sending ^? when running interactive commands like pacman or ed after this and I don't know how to change that other than exiting the terminal (edit: stty sane fixes both this and the no echo issue, for anyone else who encounters this). However, some REPL shells like python, node or iex (elixir REPL) doesn't have this issue.

Huy-Ngo commented 3 weeks ago

OK I can confirm that this happens with ed on alpine, but not apk, so it's probably not a distro issue

Huy-Ngo commented 3 weeks ago

OK it turns out that this depends on shell too: I encountered this bug on bash, but not zsh or fish. zsh also has the ^M bug, though.

Meanwhile ksh and dash would be borked entirely and "enter" doesn't even work on the main shell