[Bug] Prompts never settle when stdin ends
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- OS: macOS
- Node Version: v22.23.2 and v26.0.0
- Package:
@clack/core(through@clack/prompts) - Package Version:
@clack/prompts1.8.1,@clack/core1.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.
- Ngôn ngữ chính
- TypeScript
- Star
- 8.1k
- Fork
- 218
- Merge trung bình
- 1 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bombshell-dev/clack
-
[Bug]Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 12/100
bombshell-dev/clack#619 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
bombshell-dev/clack#613 · 4 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
bombshell-dev/clack#597 ·
-
rfc: accessible modeĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
bombshell-dev/clack#585 · 1 bình luận · 1 reaction ·
-
[Bug] Spinner does not run `onCancel` function on `Ctrl + C`Có thể đã có người làm @cyphercodes đã nhận 107 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
bombshell-dev/clack#573 · 1 bình luận · 2 reaction ·
Tất cả issue của bombshell-dev/clack
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
melgarafael/DeskcommCRM#3000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
callstackincubator/simlock#639 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
aws/agentcore-cli#2606 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
🐛 [BUG] - FeatureComparisonTable text-only cells are top-aligned while icon cells are centeredĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 7 ngày
-
ai-driven-qa bug Cosmetic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày