Skip to content

gateway-lock: file descriptor leak when writeFile fails after acquiring lock #98958

Description

@zhangLei99586

Summary

In src/infra/gateway-lock.ts:264-286, when fs.open(lockPath, "wx") succeeds but handle.writeFile() fails (e.g. disk full), the code throws GatewayLockError without closing the file handle, leaking a file descriptor.

Reproduction

Source inspection: the inner writeFile call on line 275 is not wrapped in a try-catch that closes the handle on failure.

Expected

Close the fd and remove the partial lock file before re-throwing.

Scope

src/infra/gateway-lock.ts — 1 file, ~5 LoC change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions