Skip to content

Resume stdin in the password prompt - #16

Merged
dennisdornon merged 1 commit into
mainfrom
fix-password-prompt-resume
Nov 25, 2026
Merged

dennisdornon merged 1 commit into
mainfrom
fix-password-prompt-resume

Conversation

@dennisdornon

@dennisdornon dennisdornon commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #12.

When mainwpcontrol login prompts for the Dashboard URL or username, readline closes and leaves stdin paused. promptForPassword then adds a data listener, which doesn't restart a paused stream, so nothing keeps the event loop alive and Node exits at the password prompt with "Detected unsettled top-level await". This happens on any supported Node version, not only Node 26.

promptForPassword now calls stdin.resume() after attaching its listener. It still pauses stdin again when the password is entered.

New tests in src/utils/prompt.test.ts cover the paused-stdin case and check that stdin is paused and raw mode restored afterwards. The first test times out without the fix.

Typecheck, lint, npm test (1079), npm run test:process (109) and build pass locally. A URL prompt followed by the password prompt also works under a pseudo-terminal on Node 24.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed password entry when input is paused, preventing the prompt from becoming unresponsive.
    • Password entry continues to restore terminal input settings after completion.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

promptForPassword now resumes stdin after attaching its data listener. Tests cover password entry when stdin is paused and verify that the prompt restores raw mode and pauses stdin after input.

Changes: Password prompt

Layer / File(s) Summary
Resume stdin and verify prompt behavior
src/utils/prompt.ts, src/utils/prompt.test.ts
promptForPassword resumes stdin after registering its data listener. Tests verify that paused stdin accepts a password and that the prompt restores raw mode and pauses stdin.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to c9e99

This change fixes the login password prompt hanging when stdin is left paused after earlier prompts. The change is small, its terminal cleanup behavior is unchanged, and tests cover it, so the merge risk is minimal.

Security architecture risk: Minimal · up to c9e99

Interactive login can now accept a password after asking for the Dashboard URL or username. The fix keeps password input masked and does not change how login handles credentials.

Pre-merge checks: Passed 6

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Resume stdin in the password prompt" names the main change: promptForPassword now calls stdin.resume() after attaching its data listener, which fixes the login hang reported in issue #12. I…
Linked Issues check Passed Issue #12 reports that mainwpcontrol login exits at the application-password prompt with "Detected unsettled top-level await". The issue has no separate acceptance criteria. The coding requirement i…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes only src/utils/prompt.ts (+4 lines: stdin.resume() and comments) and adds src/utils/prompt.test.ts (+66 lines). Both changes address the paused-s…
Public Contract Compatibility Passed The check covers public hooks, REST routes, abilities, database schemas, serialized data, and Dashboard-to-Child action payloads. The PR changes two files: src/utils/prompt.ts (+4 lines) and a new `…
Validation Evidence Passed The change is executable. It modifies src/utils/prompt.ts (+4 lines) and adds tests in src/utils/prompt.test.ts (+66 lines), so the validation evidence rule applies. The PR description records the…
Full details: Title check

Explanation

The title "Resume stdin in the password prompt" names the main change: promptForPassword now calls stdin.resume() after attaching its data listener, which fixes the login hang reported in issue #12. It is specific and matches the changeset and PR objectives.

Full details: Linked Issues check

Explanation

Issue #12 reports that mainwpcontrol login exits at the application-password prompt with "Detected unsettled top-level await". The issue has no separate acceptance criteria. The coding requirement is that the password prompt keeps the event loop alive after readline leaves stdin paused. The base-to-head diff of src/utils/prompt.ts adds stdin.resume() after stdin.on('data', onData) in promptForPassword, with comments explaining the paused-stream cause. The diff of src/utils/prompt.test.ts adds a new test file. Its first test sets stdin.pause() before calling promptForPassword and asserts that the password resolves. Its second test asserts that setRawMode(true) is called first, setRawMode(false) is called last, and stdin stays paused afterward. The requirement is implemented and covered by a test. I did not run the test suite. The author reports npm test (1079) and npm run test:process (109) as passing.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes only src/utils/prompt.ts (+4 lines: stdin.resume() and comments) and adds src/utils/prompt.test.ts (+66 lines). Both changes address the paused-stdin cause in #12. No unrelated files or hunks were found in the reviewed diffs.

Full details: Public Contract Compatibility

Explanation

The check covers public hooks, REST routes, abilities, database schemas, serialized data, and Dashboard-to-Child action payloads. The PR changes two files: src/utils/prompt.ts (+4 lines) and a new src/utils/prompt.test.ts. The prompt.ts diff only adds stdin.resume() and a comment inside promptForPassword, after the existing stdin.on('data', onData) listener. It changes no function signature, return value, hook, route, ability, schema, serialized format, or action payload. The change fixes stdin state for the CLI password prompt, which the check does not cover. Per the PR description, stdin is still paused again after the password is entered. No compatibility path or coordinated consumer update is needed for this change.

Full details: Validation Evidence

Explanation

The change is executable. It modifies src/utils/prompt.ts (+4 lines) and adds tests in src/utils/prompt.test.ts (+66 lines), so the validation evidence rule applies. The PR description records these validation commands and outcomes, all reported as passing locally: - Typecheck - Lint - npm test (1079 tests) - npm run test:process (109 tests) - Build - A manual URL-then-password flow under a pseudo-terminal on Node 24 The description also states that the first new test times out without the fix. That is a stated reproduction of the failure. The check does not require the tests to be run, and I did not execute them. The outcomes are author-provided evidence. The check fails only when both validation evidence and an explicit verification limitation are absent. Here, validation evidence is present, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4084dc7c-652c-45aa-8e0b-a557df0727ae
Commits

Reviewing files that changed from the base of the PR and between 0025a0e and c9e990a.

Files selected for processing: 2

  • src/utils/prompt.test.ts
  • src/utils/prompt.ts

Included review availability: This review used your included allowance. 5 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: CodeRabbit Security
Additional context used

Path-based instructions: 1

Check request and response contracts, unsafe HTML insertion, exposed credentials, stale asynchronous responses, and error handling.

CodeRabbit configuration file

Files:

  • src/utils/prompt.test.ts
  • src/utils/prompt.ts
Additional comments: 2

src/utils/prompt.ts: 1

159-162: LGTM!

src/utils/prompt.test.ts: 1

1-66: LGTM!

When login asks for the URL or username first, readline leaves stdin paused, and the password prompt's data listener never received input. Node then exited at the prompt with an unsettled top-level await warning.
@dennisdornon
dennisdornon force-pushed the fix-password-prompt-resume branch from c6b6866 to c9e990a Compare November 25, 2026 17:49
@dennisdornon

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

@dennisdornon
dennisdornon merged commit 3265793 into main Nov 25, 2026
11 checks passed
@dennisdornon dennisdornon mentioned this pull request Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Warning: Detected unsettled top-level await"

1 participant