Skip to content

fix(stdin): retry transient nonblocking reads - #713

Open
ALV0612 wants to merge 4 commits into
openai:mainfrom
ALV0612:fix/issue-247-retry-nonblocking-stdin
Open

fix(stdin): retry transient nonblocking reads#713
ALV0612 wants to merge 4 commits into
openai:mainfrom
ALV0612:fix/issue-247-retry-nonblocking-stdin

Conversation

@ALV0612

@ALV0612 ALV0612 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • force piped stdin into blocking mode when supported
  • retry only transient EAGAIN/EWOULDBLOCK reads with bounded synchronous backoff
  • preserve TTY, ordinary pipe, and non-transient error behavior
  • add deterministic regression coverage

Verification

  • focused tests: 5/5 pass
  • full suite: 96/96 pass
  • build and version checks pass
  • OpenSpec strict validation and git diff --check pass

Fixes #247

@ALV0612
ALV0612 requested a review from a team September 2, 2026 10:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88dbb5ed13

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/fs.mjs Outdated

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The retry budget is cumulative rather than consecutive here. transientAttempts and retryDelayMs never reset after a successful readSync, so a long pipe that makes progress between sporadic EAGAINs still fails on the Nth transient error, and later retries stay at the max backoff. I think both should reset after bytesRead > 0; a data → EAGAIN → data loop repeated past maxAttempts would pin it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fdba42d1a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/codex/scripts/lib/fs.mjs Outdated
Comment on lines +79 to +81
transientAttempts += 1;
if (!isTransientReadError(error) || transientAttempts >= maxAttempts) {
throw error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep retrying while a pipe remains open

When setBlocking(true) is unavailable and a producer leaves its pipe open without supplying the next chunk for about 1.13 seconds, the eighth EAGAIN is thrown even though it is neither EOF nor an invalid descriptor. For example, a delayed or intermittently streaming piped prompt will fail instead of being read in full; the normal blocking-read behavior has no equivalent timeout. Continue waiting until data or EOF arrives (or expose an explicit caller timeout) rather than treating a fixed retry count as a read failure.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in af3e94b. Transient EAGAIN/EWOULDBLOCK no longer has an attempt ceiling while the pipe remains open; the loop waits with capped backoff until data or EOF, and still throws non-transient errors immediately. Added a 20-consecutive-transient regression before eventual progress.

@ALV0612

ALV0612 commented Sep 2, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: af3e94bff6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

codex-companion crashes with EAGAIN on concurrent sessions (readStdinIfPiped sync read)

2 participants