Repository navigation
Description
What
Before deploy or update changes anything, it asks a yes/no question on the terminal. If the person presses Ctrl-D (end of input) instead of answering, the question is never answered. Node then exits with code 13 and prints "Warning: Detected unsettled top-level await", instead of the CLI's own exit 7 and "Nothing was created." Scripts and agents rely on the documented exit codes (7 means "No yes: declined ... nothing was created"), and 13 isn't one of them. Treating end of input as "no" gives the documented result.
Where to look
packages/cli/src/system.ts, lines 120-128,confirm:When input ends, readline closes the interface and theconst rl = createInterface({ input: process.stdin, output: process.stderr }); try { const answer = await new Promise<string>((resolve) => rl.question(question, resolve));
questioncallback never runs. Listen for the interface'scloseevent too, and resolve with an empty answer.packages/cli/src/bin.ts, line 5: the CLI runsmainwith top-levelawait. That is why an unsettled promise turns into exit 13.packages/cli/src/deploy-track.ts, lines 816-833: what happens with afalseanswer (aCliErrorwithnot-confirmed, exit 7).confirmreadsprocess.stdindirectly, which is hard to test. A small helper that takes the input and output streams, used byconfirm, can be tested with aPassThroughfromnode:streamthat you end at once.system.tshas no test file yet. Use the style ofpackages/cli/test/version.test.ts.- Leave Ctrl-C as it is. This issue is only about end of input.
Done when
- With input that ends before any answer, the question resolves to "no". A test with an ended
PassThroughshows this, and it hangs or fails without the change (give it a short timeout). - Answers
y,yesandYESstill mean yes, and anything else means no, as/^y(es)?$/isays today. A test covers these. pnpm verifypasses.
How to check
pnpm install
pnpm --filter gateweave test
pnpm verifyTo see it by hand, after pnpm build: run node packages/cli/dist/bin.js deploy track in a terminal against an empty rehearsal account, and press Ctrl-D at the question. Only do this in a separate, empty Cloudflare account, as CONTRIBUTING.md says. The unit test is enough for the pull request.
The draft pull request #18 changes the same files (main.ts, system.ts). If it merges before you open yours, rebase on main first.
Setup is in CONTRIBUTING.md. Say here if you're taking this, so nobody does it twice, and ask here if you get stuck.
Activity