fix(hooks): prevent fd leak in estimateContextPercent#2178
Merged
Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom Apr 5, 2026
Merged
fix(hooks): prevent fd leak in estimateContextPercent#2178Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom
Yeachan-Heo merged 1 commit intoYeachan-Heo:devfrom
Conversation
The .cjs version declares `const fd` inside the try block, so if readSync throws, the catch block cannot close the descriptor (fd is out of scope). The .mjs version (line 516) and pre-tool-enforcer.mjs (line 161) both correctly use `let fd = -1` before the try block with a finally clause for cleanup. Align the .cjs version with the established pattern: declare fd before try, set to -1 after successful close, add finally block for best-effort cleanup on error.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Owner
|
CI green, merge-ready.\n\n—\n*[repo owner'''s gaebal-gajae (clawdbot) 🦞]* |
Yeachan-Heo
added a commit
that referenced
this pull request
Apr 5, 2026
This restores the pre-jonckr runtime, hook, and team behavior by reverting the five owner-scoped merge commits on top of origin/dev. The rollback stays narrowly focused on the affected source/script surfaces so reviewers can audit the history against the original PRs. Constraint: Owner-directed rollback to pre-jonckr runtime behavior after CI/base-red fallout Constraint: Must revert merge commits #2175 #2176 #2177 #2178 #2179 with mainline parent 1 semantics Rejected: Manual file-by-file rollback | weaker audit trail and easier to miss behavior edges Rejected: Partial rollback that keeps #2177-#2179 fixes | conflicts with the requested rollback scope Confidence: medium Scope-risk: moderate Reversibility: clean Directive: Reassess the reverted hook contract, fd-cleanup, and macOS version-sync behavior before reintroducing any of these changes Tested: npx vitest run src/team/__tests__/tmux-session.test.ts Tested: npx vitest run src/__tests__/pre-tool-enforcer.test.ts src/__tests__/bedrock-lm-suffix-hook.test.ts Tested: npx vitest run src/hooks/persistent-mode/stop-hook-blocking.test.ts Tested: node version consistency check for package/plugin/marketplace versions Tested: npx tsc --noEmit Tested: npm run lint Tested: npm run build Tested: npm pack + local prefix install smoke (`omc --version`, `omc --help`) Not-tested: Full `npm test -- --run` remains red on `src/__tests__/hooks-command-escaping.test.ts` with an unrelated Windows-style plugin-root path failure outside the reverted files Related: PR #2175 Related: PR #2176 Related: PR #2177 Related: PR #2178 Related: PR #2179
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
estimateContextPercentinpersistent-mode.cjsdeclaresconst fd = openSync(...)inside the try blockreadSyncthrows, the catch block cannot close the descriptor becausefdis out of scope.mjsversion of the same function (line 516) correctly useslet fd = -1before the try block with a finally clausepre-tool-enforcer.mjs(line 161) andcontext-guard-stop.mjs(line 139) also use the correct patternFix
Align the
.cjsversion with the established pattern:let fd = -1before the try blockfd = -1after successfulcloseSync(prevent double-close)finallyblock for best-effort cleanup on errorTest plan
.mjsversion (line 516),pre-tool-enforcer.mjs(line 161), andcontext-guard-stop.mjs(line 139) all uselet fd = -1with finally.cjshad no fd cleanup (justreturn 0)