Skip to content

kimi web server process crashes with uncaught AbortError when pausing a goal with a queued continuation #2801

Open

Description

@LoG1331

Version

0.34.0 (native binary, Linux x64)

What happened

While using the web UI served by kimi web, pausing a goal on a session whose goal had a continuation in flight killed the entire server process:

Error [AbortError]: Goal continuation cancelled
    at AgentGoalService.cancelPendingContinuation (...)
    at AgentGoalService.applyLifecycle (...)
    at AgentGoalService.pauseGoal (...)
    at SessionLegacyService.applyAgentConfig (...)
    at SessionLegacyService.updateProfile (...)

Node.js v24.x

The process exits; all other sessions served by the same daemon drop with it. Session data on disk is fine — only the server process dies.

Root cause

Two layers combine:

  1. In packages/agent-core-v2/src/agent/goal/goalService.ts, launchContinuationTurn runs a bookkeeping promise chain (receipt.assigned.then(...).finally(...)) with no catch. When the pending continuation is aborted (pauseGoal → applyLifecycle → cancelPendingContinuation → receipt.abort(...)), that chain rejects with an AbortError and becomes an unhandled rejection.
  2. In packages/telemetry/src/crash.ts, the unhandledRejection handler deliberately rethrows when it is the sole listener (print/server modes) to preserve Node's crash-on-rejection behavior — but it rethrows even for AbortError, which it otherwise classifies as expected cancellation noise and skips for tracking.

The same pause in the TUI survives because the TUI registers its own rejection handling; the daemon path has no such boundary.

Minimal reproduction

With the telemetry crash handlers installed and no other unhandledRejection listener (the daemon's shape):

installCrashHandlers();
const abort = new Error('Goal continuation cancelled');
abort.name = 'AbortError';
Promise.reject(abort); // unhandled, like the goal continuation bookkeeping chain

The process exits with throw reason from the rejection handler. With an early return for abort-shaped rejections, the process survives; non-abort rejections still crash as intended.

End-to-end: create a session via the web API, start a goal, let it reach a goal-driven continuation turn, then POST /api/v1/sessions/{id}/profile with {agent_config:{goal_control:pause}} — the daemon exits.

Suggested fix

  • Swallow the rejection in the continuation bookkeeping chain (it only cleans up bookkeeping state; real turn failures already surface via turn.ended events).
  • In the telemetry rejection handler, return early for AbortError instead of rethrowing it.

Happy to send a PR with both changes plus a regression test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions