fix: close readline interface and destroy read stream in transcript store#98140
fix: close readline interface and destroy read stream in transcript store#98140zhangLei99586 wants to merge 2 commits into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: this PR is superseded by the merged canonical transcript cleanup PR; current main has the same stream/readline cleanup plus focused fd-leak regression tests, and this branch is now conflicting with no meaningful unique remainder. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: The sibling PR #98493 merged on July 1, 2026 and added the same cleanup plus tests, closing #98467. So I’m closing this here and keeping the remaining discussion on #98493 and #98467. Review detailsBest possible solution: Keep the merged current-main cleanup and regression tests from the canonical PR, and close this conflicting duplicate branch. Do we have a high-confidence way to reproduce the issue? Yes, source-level: the pre-fix bounded transcript reader created readline over an inline stream and could exit on JSON.parse throw without local cleanup. Current main now has Linux fd regression tests for malformed JSON and happy-path cleanup. Is this the best way to solve the issue? No for this branch. A same-or-better fix with focused tests already landed through #98493, so merging this conflicting branch is no longer the best path. Security review: Security review cleared: The diff only changes local transcript file stream cleanup and does not touch dependencies, workflows, package metadata, permissions, credentials, or secrets. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 5002a0e9ea99; fix evidence: commit 94cb14b97ead, main fix timestamp 2026-07-01T04:52:13-07:00. |
zhangLei99586
left a comment
There was a problem hiding this comment.
@clawsweeper re-review
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper review |
The createReadStream and readline.createInterface were not cleaned up after use. If JSON.parse threw inside the loop, the file descriptor remained open. Wrap the loop in try/finally to close the readline interface and destroy the underlying stream, ensuring the file descriptor is always released.
a49365d to
f6e7dd1
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
|
@clawsweeper re-review |
2 similar comments
|
@clawsweeper re-review |
|
@clawsweeper re-review |
stream.destroy() starts async teardown but returns immediately, so the fd could still be open when the method rethrows. Wait for the 'close' event when the stream is not already closed to ensure the descriptor is released before the caller handles the rejection.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review |


Related: #98467
What Problem This Solves
createReadStream+readline.createInterfacenot cleaned up afterfor awaitloop — fd leaks onJSON.parsethrow.Why This Change Was Made
Wrap loop in
try/finallythat callslines.close()andstream.destroy().User Impact
No user-visible change. Prevents fd exhaustion reading large transcripts.
Evidence
Runtime terminal proof:
transcripts-tool.test.ts) —stream.destroyed: trueconfirmed at runtime