Skip to content

[Tech-Debt]: Use of generic Error for process exit simulation causes swallowed control-flow exceptions #97796

Description

@aniruddhaadak80

What Problem This Solves

In the CLI runtime environment, createNonExitingRuntime() simulates a process exit by throwing a generic new Error("exit ${code}"). This is a dangerous anti-pattern because upstream try-catch blocks designed to catch real runtime crashes will accidentally catch this control-flow signal, logging it as a bug rather than terminating the CLI command.

Expected vs Actual Behavior

Expected: The runtime should throw a specific subclass (e.g., class ExitError extends Error) so upstream callers can explicitly check if (err instanceof ExitError) and respect the simulated exit.
Actual: It throws a generic Error.

Code Link

https://github.com/openclaw/openclaw/blob/main/src/runtime.ts#L98-L105

Proposed Solution

Introduce a strongly-typed ExitError class in runtime.ts and update createNonExitingRuntime to throw it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-priority cleanup, docs, polish, ergonomics, or speculative work.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions