Skip to content

Conversation

@antongolub
Copy link
Collaborator

  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub added the refactoring Internal code improvements label Aug 6, 2025
@antongolub antongolub requested a review from Copilot August 6, 2025 11:02
@antongolub antongolub added the bug label Aug 6, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the ProcessPromise[asyncIterator] implementation to simplify the logic for handling different stdout stream types. The main change replaces a conditional check for async iterator support with a simpler fallback to an empty array.

  • Simplifies stdout iteration logic in the async iterator implementation
  • Updates test to use sleep() helper function instead of manual Promise construction
  • Adds comprehensive test coverage for edge cases involving ignored and non-iterable stdio configurations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/core.ts Simplifies stdout iteration logic by replacing conditional async iterator check with empty array fallback
build/core.cjs Generated build artifact reflecting the core.ts changes
test/core.test.js Refactors existing test and adds new test cases for stdio edge cases
.size-limit.json Updates bundle size limits to reflect the code simplification

for await (const chunk of this.stdout[Symbol.asyncIterator]
? this.stdout
: VoidStream.from(this.stdout)) {
for await (const chunk of this.stdout || []) {
Copy link

Copilot AI Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback to an empty array [] may not handle all cases correctly. If this.stdout is a non-iterable object (like a file descriptor), this will silently skip iteration instead of properly handling the stream. The original code with VoidStream.from() was likely designed to handle such cases.

Suggested change
for await (const chunk of this.stdout || []) {
for await (const chunk of VoidStream.from(this.stdout)) {

Copilot uses AI. Check for mistakes.
@antongolub antongolub merged commit 3188694 into google:main Aug 6, 2025
28 checks passed
@antongolub antongolub deleted the refactor-pp-iterator branch August 6, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug refactoring Internal code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant