Skip to content

[app-bug] /api/analyze temp dir leaks when CLI errors or hits the 30s timeout #861

@Gbangbolaoluwagbemiga

Description

@Gbangbolaoluwagbemiga

Problem

/api/analyze writes the uploaded contract to a mkdtemp directory before invoking the CLI. The cleanup (rm) is not in a finally that always runs — if the CLI subprocess throws or the timeout-kill path fires, the temp dir is leaked.

Acceptance Criteria

  • Wrap the body of the handler in try { ... } finally { await rm(tmpDir, { recursive: true, force: true }); }
  • Add a unit test that simulates a CLI timeout and asserts the dir is gone after the response resolves
  • If we can't run the CLI in tests, mock the subprocess

Pointers

Difficulty

Easy. Pure correctness fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions