fix: Do not block in ChainedProcessorManager.next(). #20321
[P2] Clean up rest processors that arrive after close
Once restFuture has already been resolved, close() cannot cancel it; a pending rest.next() can therefore still resolve with a ProcessorAndCallback after the manager is closed. nextFromRest() forwards that value without checking closed or cleaning up the returned FrameProcessor, unlike the first-phase callback above. During a failure or cancellation, RunAllFullyWidget can discard this late processor after its manager has been closed, leaving its channels or other resources uncleaned. Route rest.next() through the same post-close cleanup path (or otherwise cancel/track the in-flight future).
🟡 Changes recommended
The change removes the blocking wait from the first phase and synchronizes the phase transition correctly. One cleanup race remains in the asynchronous rest phase: after the rest manager has been created, a pending rest.next() can resolve after close and return a processor that is no longer owned by the executor. That processor needs the same post-close cleanup handling as processors returned by the first phase.
Reviewed 2 of 2 changed files. This was a static review; no local build or test commands were run.
| Severity | Findings |
| --- | ---: |
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
<!-- mergelens:review -->
---
This is an automated review by Codex GPT-5.6 Luna(Max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
Fixed this by adjusting the contract so RunAllFullyWidget handles the closing.
Follow-up review: this addresses my cleanup concern. RunAllFullyWidget.cleanupNextProcessor() now tracks the outstanding next() future before processorManager.close(), so a ProcessorAndCallback that resolves after close is cleaned instead of discarded. The added regression test covers this failure path. Reviewed 5 of 5 changed files.
<!-- mergelens:review -->
[P2] Complete pending next futures on close
Finding: When the first phase has returned empty but its processors are still completing, next() can already be waiting on nextFromRest(). If the run then fails or is cancelled, close() sets closed, so checkFirstProcessorComplete() will never set restFuture; because this close path no longer cancels it, the returned future remains permanently pending and retains the waiting callback.
Suggestion: Restore close-time cancellation of restFuture, or otherwise complete every outstanding nextFromRest() future after marking the manager closed.
🟡 Changes recommended
Close-time cancellation of restFuture was removed, leaving some next() futures permanently pending after failure or cancellation. Restore completion/cancellation of those futures before merging. The prior late-processor cleanup race is addressed by cleanupNextProcessor.
Reviewed 5 of 5 changed files. This updated-since-review pass started with the supplied incremental diff, then covered the full current PR diff and relevant executor/manager code. Static review only; no build or test commands were run.
| Severity | Findings |
| --- | ---: |
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
<!-- mergelens:review -->
---
This is an automated review by Codex GPT-5.6-Luna(max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
Restored close-time cancellation of restFuture.
🟢 Approval recommended
The prior pending-restFuture issue is fixed by canceling restFuture on close, and the new regression test covers a pending nextFromRest() future. I also reviewed the full merge-base diff, the incremental fix, the FrameProcessorExecutor/RunAllFullyWidget lifecycle, all in-repository ProcessorManager implementations, and the ChainedProcessorManager call sites. No actionable correctness, concurrency, cleanup, or compatibility issues remain.
Reviewed 5 of 5 changed files.
Validation: the local merge simulation against origin/master completed cleanly and git diff --check passed. No build or test commands were run.
<!-- mergelens:review -->
---
This is an automated review by Codex GPT-5.6 Luna(Max)
Approved these changes.
clintropolis
gianm
Previously, a blocking Future wait ran inside next(), which could cause a processing thread to block while waiting for the next processor to be ready. This patch fixes it by moving resolution to a callback.