fix(convert): read stdin as a stream and guard against TTY-only invocations#184
Merged
Conversation
…ations `fs.readFileSync(process.stdin.fd, 'utf-8')` is fragile across platforms and silently hangs when the command is run interactively without piped input. Replace it with an async stream consumer and surface a clear error when stdin is a TTY.
github-actions Bot
pushed a commit
that referenced
this pull request
May 12, 2026
## [2.6.3](v2.6.2...v2.6.3) (2026-05-12) ### Bug Fixes * **convert:** read stdin as a stream and guard against TTY-only invocations ([#184](#184)) ([fda2860](fda2860))
|
🎉 This PR is included in version 2.6.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
convertcommand read stdin viafs.readFileSync(process.stdin.fd, 'utf-8'). That's a known-fragile pattern: it can hitEAGAINon some platforms, and when the user invokes the command interactively (no pipe, no--input-file) the process just hangs forever waiting on the TTY.process.stdin.isTTYis true.Test plan
npm test— 680/680 passnpm run lint— clean# Piped\n...reads via stdin, empty pipe (input: '') returns empty output without hangingecho '# Hi' | confluence convert --input-format markdown --output-format storageworks;... </dev/nullreturns emptyNot in automated tests
The TTY guard itself isn't covered by Jest —
execFileSyncalways attaches pipes to the child, soprocess.stdin.isTTYis alwaysfalsein the test harness. Verifying the TTY branch would require a pty wrapper (node-ptyor similar), which felt like overkill for a 4-lineif (isTTY) { console.error; exit(1) }. Reviewed by inspection instead.