Skip to content

Mid-session crash leaves ordering-dependent terminal status (onclose can downgrade "error" → "disconnected") #1490

Closed

Description

@cliffhall

Background

Discovered during the #1489 re-review (follow-up to #1323).

On a real mid-session transport crash, many SDK transports fire both onclose and onerror, in a transport-dependent order. After #1489, the error event (and thus lastError / the toast) surfaces in both orderings — that goal is fully met. But the persistent status the client lands on still differs by ordering:

  • onerror-then-onclose → final status "disconnected" — the trailing onclose overwrites "error" via the if (this.status !== "disconnected") guard at core/mcp/inspectorClient.ts:432.
  • onclose-then-onerror → final status "error".

So two transports can leave different steady-state status after an identical crash.

Why it's currently benign

The web UI consumes the crash reason via lastError (always set in both orderings), not status === "error", so the toast fires either way. This is informational today.

When it would matter

If any consumer (web/TUI/CLI) ever branches on status === "error" to render a distinct errored state vs. a clean disconnect, the asymmetry would make that branch transport-dependent.

Possible fix

Don't let onclose downgrade an "error" status — e.g. in the onclose handler treat "error" as terminal (only transition "connected"/"connecting" → "disconnected"), or have the crash path settle on a single canonical terminal status.

Scope note

Out of scope for #1323/#1489 (which only surface the reason). Filing so the property is tracked rather than a future surprise.

Metadata

Metadata

Assignees

Labels

v2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions