Skip to content

[Bug]: Unhandled persistence failures in chat-abort.ts silently swallow errors and risk memory leaks #97795

Description

@aniruddhaadak80

What Problem This Solves

In the gateway's chat abort handling, if the project session terminal persistence fails, the promise catch block silently deletes the abort controller without logging the error. This means terminal states can fail to persist in production without any trace in the telemetry or logs.

Expected vs Actual Behavior

Expected: If a critical background persistence operation fails, it should be logged via log.error so operators can monitor database or file-system health.
Actual: The error is swallowed completely.

Code Link

https://github.com/openclaw/openclaw/blob/main/src/gateway/chat-abort.ts#L168-L180

Proposed Solution

Add proper error logging inside the .catch() block:

.catch((err) => {
  log.error?.(`Failed to persist chat abort terminal state for run ${params.runId}: ${err}`);
  if (params.chatAbortControllers.get(params.runId)?.controller === controller) {
    params.chatAbortControllers.delete(params.runId);
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.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.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