fix: flush integrated output stream before finish #556
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.
DISCLAIMER: FIX IMPLEMENTED BY LLM AGENT
fixes #530
The integrated strategy's
output_stream()has a race condition whereoutput_finish_futurecan resolve before asynchronous stdout pushescomplete.
on_stdoutschedulesoutput_accum:push()vianio.run(), so thepush does not execute until the scheduler resumes the task. When EOF arrives,
output_finish_future.set()ran synchronously and could beat the pendingpushes, causing
stream()to returnnilwhile buffered data still existed.Fix by tracking in-flight stdout pushes and defer setting the finish future
until all scheduled pushes finish. This keeps the stream alive until all
buffered stdout has been delivered, eliminating the race in fast or
sandboxed environments (e.g. Nix builds, CI) where the issue reproduced.
Fixes the "integrated strategy streams output" regression on Linux when the
scheduler services the finish future before pending stdout writes.
Nix sandbox tests error: