Skip to content

fix: end async iteration when output streams are disabled - #182

Merged
43081j merged 3 commits into
tinylibs:mainfrom
dailyun:codex/finish-iteration-without-output-streams
Oct 28, 2026
Merged

43081j merged 3 commits into
tinylibs:mainfrom
dailyun:codex/finish-iteration-without-output-streams

Conversation

@dailyun

@dailyun dailyun commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Async iteration never finishes when neither stdout nor stderr is piped, even after the child exits. For example:

const proc = x(process.execPath, ['-e', ''], {
  nodeOptions: { stdio: 'ignore' }
});
for await (const line of proc) console.log(line);
console.log('finished'); // never reached before this fix

combineStreams([]) creates a stream that nobody ends. End it immediately when there are no inputs. The iterator still waits for the child to close, so throwOnError continues to report nonzero exits. This also fixes stdio: 'inherit' without changing output capture.

All four new regression cases time out on the previous code and pass with the fix. Full suite: 55 passed, 10 skipped on Node 24.19.0 and via the Bun 1.4.3 build/test command. Build, lint (including TypeScript and publint), and formatting pass.

Implemented and tested with Codex assistance.

Comment thread src/test/stream_test.ts Outdated
Comment thread src/stream.ts
@43081j
43081j merged commit 4a2aca1 into tinylibs:main Oct 28, 2026
9 checks passed
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.

2 participants