Skip to content

app-server: harden command/exec drain and lifecycle races#13696

Open
euroelessar wants to merge 1 commit intomainfrom
ruslan/exec-stream-harden
Open

app-server: harden command/exec drain and lifecycle races#13696
euroelessar wants to merge 1 commit intomainfrom
ruslan/exec-stream-harden

Conversation

@euroelessar
Copy link
Contributor

@euroelessar euroelessar commented Mar 6, 2026

Close the remaining post-exit and control-path races by draining tail output with a quiet window plus a bounded final ready pass, and by returning consistent not-running errors after a process has already exited.

Logic is primarily complicated in order to handle a case where child process did spawn some grand-children processes which inherit its stdout pipe (and therefore something may still continue writing there).

Add a dedicated helper binary and focused tests so the lifecycle behavior is reviewable on its own, and reject Windows disableTimeout requests that the buffered fallback cannot honor.

@euroelessar euroelessar force-pushed the ruslan/exec-stream-harden branch 2 times, most recently from e01940e to e41718f Compare March 6, 2026 07:13
@euroelessar euroelessar force-pushed the ruslan/exec-stream-harden branch from e41718f to 1de71cd Compare March 6, 2026 07:58
@euroelessar euroelessar force-pushed the ruslan/exec-stream branch 2 times, most recently from e2cc0a2 to 0628035 Compare March 6, 2026 21:26
Base automatically changed from ruslan/exec-stream to main March 7, 2026 01:30
Close the remaining post-exit and control-path races by draining tail output with a quiet window plus a bounded final ready pass, and by returning consistent not-running errors after a process has already exited.

Add a dedicated helper binary and focused tests so the lifecycle behavior is reviewable on its own, and reject Windows disableTimeout requests that the buffered fallback cannot honor.
@euroelessar euroelessar force-pushed the ruslan/exec-stream-harden branch from 1de71cd to 58a5bd9 Compare March 7, 2026 01:33
@euroelessar euroelessar requested a review from owenlin0 March 7, 2026 01:34
@euroelessar
Copy link
Contributor Author

@codex review

Copy link
Contributor

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

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: 58a5bd9c55

ℹ️ 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 on lines +666 to +670
if drained_any {
if let Some((quiet_deadline, _)) = post_exit_deadlines.as_mut() {
*quiet_deadline = Instant::now() + post_exit_quiet_period;
}
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Enforce post-exit hard cap when output never goes quiet

collect_process_output resets the quiet deadline and continues whenever any chunk is drained. Once hard_deadline has elapsed, ready_drain_limit only caps a single inner try_recv pass; the outer loop immediately starts another pass, so continuous grandchild output can keep this task alive forever. run_command then waits indefinitely on stdout/stderr join handles, delaying response/session cleanup.

Useful? React with 👍 / 👎.

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