Skip to content

fix: close readline interface and destroy read stream in transcript store#98140

Closed
zhangLei99586 wants to merge 2 commits into
openclaw:mainfrom
zhangLei99586:fix/readline-stream-leak
Closed

fix: close readline interface and destroy read stream in transcript store#98140
zhangLei99586 wants to merge 2 commits into
openclaw:mainfrom
zhangLei99586:fix/readline-stream-leak

Conversation

@zhangLei99586

@zhangLei99586 zhangLei99586 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Related: #98467

What Problem This Solves

createReadStream + readline.createInterface not cleaned up after for await loop — fd leaks on JSON.parse throw.

Why This Change Was Made

Wrap loop in try/finally that calls lines.close() and stream.destroy().

User Impact

No user-visible change. Prevents fd exhaustion reading large transcripts.

Evidence

Runtime terminal proof:

screenshot

  • 10/10 tests passed (transcripts-tool.test.ts) — stream.destroyed: true confirmed at runtime

@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

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
Relationship: superseded
Canonical: #98493
Summary: The merged sibling PR is the canonical fix for the same transcript fd cleanup root cause.

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 details

Best 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:

  • wangmiao0668000666: Authored the merged sibling PR that added the same transcript stream cleanup plus focused regression tests. (role: canonical fix author; confidence: high; commits: 64bac6195c93, 94cb14b97ead; files: src/transcripts/store.ts, src/transcripts/store.test.ts)
  • vincentkoc: Merged the canonical cleanup PR and closed another same-root transcript cleanup PR as covered by that canonical fix. (role: merger and duplicate cleanup; confidence: high; commits: 94cb14b97ead; files: src/transcripts/store.ts, src/transcripts/store.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 5002a0e9ea99; fix evidence: commit 94cb14b97ead, main fix timestamp 2026-07-01T04:52:13-07:00.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 30, 2026

@zhangLei99586 zhangLei99586 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@clawsweeper re-review

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@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.
@zhangLei99586
zhangLei99586 force-pushed the fix/readline-stream-leak branch from a49365d to f6e7dd1 Compare July 1, 2026 06:30
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

1 similar comment
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

Runtime behavior proof — terminal output from after-fix execution:

proof

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

Runtime behavior proof (terminal output):

proof

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

2 similar comments
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 1, 2026
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.
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 1, 2026
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 2, 2026
@zhangLei99586

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@vincentkoc vincentkoc self-assigned this Jul 6, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Closing as superseded by #98493, which landed the same readline/stream cleanup in commit 94cb14b. Thanks for the contribution.

@vincentkoc vincentkoc closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants