Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

[Bug] Prompts never settle when stdin ends

Ouverte
#615 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
Une demi-journée
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
cli

Piste de recherche

The hang comes from prompt() in packages/core/src/prompts/prompt.ts, which settles only on submit and cancel (around lines 185-196), so start there and look at how the input stream is wired in. Reproduce with node repro.mjs < /dev/null using the snippet in the issue. Done means a prompt whose input ends (or has already ended) resolves with the cancel symbol, and both repro runs print 'settled with cancel' and exit 0. Check first that maintainers agree on cancel as the behaviour, since the reporter has asked.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Environment

  • OS: macOS
  • Node Version: v22.23.2 and v26.0.0
  • Package: @clack/core (through @clack/prompts)
  • 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.

To Reproduce

// repro.mjs
import { confirm, text, isCancel } from '@clack/prompts';

const ok = await confirm({ message: 'Continue?' });
console.log('confirm settled with', isCancel(ok) ? 'cancel' : ok);
const name = await text({ message: 'Name?' });
console.log('text settled with', isCancel(name) ? 'cancel' : JSON.stringify(name));
$ node repro.mjs < /dev/null
◆  Continue?
│  ● Yes / ○ No
└
Warning: Detected unsettled top-level await at file:///.../repro.mjs:3
$ echo $?
13

$ printf 'y\r' | node repro.mjs
◇  Continue?
│  Yes
confirm settled with true
◆  Name?
│  _
└
Warning: Detected unsettled top-level await at file:///.../repro.mjs:5
$ echo $?
13

Expected behavior

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.

Langage dominant
TypeScript
Étoiles
8.1k
Forks
218
Merge moyen
1 j 10 h
PR mergées (30 j)
4

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de bombshell-dev/clack

Toutes les issues de bombshell-dev/clack

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.