Skip to content

fix(interactive): process every stdin line and resolve on EOF - #447

Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/interactive-stdin-lines
Open

Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/interactive-stdin-lines

Conversation

@MohammedAlkindi

Copy link
Copy Markdown

In stdin mode, processRequests called question() once per request, so input that arrived while a request was running was lost:

  • a line typed or pasted during a request was dropped, and the rest of a multi-line paste too;
  • EOF (Ctrl+D, or the end of a pipe) left the promise pending, or rejected it with readline was closed if it came mid-request.

The Python port already reads every line and stops at EOF. The loop now iterates the readline interface, which buffers lines and ends on EOF. It prompts only while the interface is open and not paused, so readline still stops reading stdin when its line buffer fills.

The file-reading branch is untouched, so this is independent of #435.

The new test/interactive-stdin.test.ts swaps process.stdin for a stream it controls. All 5 tests fail on main; npm test gives 118 passed on Node 24.18. CI runs only build-all, not npm test.

processRequests asked one question at a time, so lines typed or pasted while a request was running were dropped, and EOF left the promise pending or rejected it. It now iterates the readline interface, which buffers lines and ends on EOF, and prompts only while input is not paused so readline keeps its backpressure.
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.

1 participant