You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Package Version: @clack/prompts 1.8.1, @clack/core 1.5.1, same on main (5ac9e73)
Describe the bug
When stdin ends while a prompt is waiting, or before it starts, the prompt never settles. await confirm(...) hangs, and in an ES module Node then exits with code 13 ("Detected unsettled top-level await"), with the cursor still hidden. It happens with closed stdin (< /dev/null, some CI runners and agent shells) and with piped input that runs out before the last prompt.
prompt() resolves only on submit and cancel (prompt.ts#L185-L196), and nothing handles the input stream ending.
The prompt settles when its input ends. Returning the cancel symbol seems the natural fit, since no answer can come and callers already handle isCancel(). With that, both runs above print "settled with cancel" and exit 0.
Additional Information
I've read #533 and the advice to skip prompts when there is no TTY. This is narrower: a prompt can still be reached with closed or piped stdin, and then it hangs with no message instead of cancelling. We hit it with @fumadocs/cli add in a non-interactive shell: it wrote the files, asked "Do you want to install with npm?", and exited 13 without installing anything.
I have a small fix in @clack/core with tests (cancel on the input's end, and right away if the input has already ended) and can open a PR if cancel is the behaviour you want.
Activity