charmbracelet/crush · warning · ErrWorkspaceGone

the server reset this workspace; reconnecting

Error message

the server reset this workspace; reconnecting

What it means

ErrWorkspaceGone means the server is reachable but no longer knows this client's workspace — it was torn down or replaced underneath the client. The subscription loop detects it and re-registers the workspace in the background, so it signals a recoverable state divergence rather than a hard failure.

Source

Thrown at internal/workspace/workspace.go:43

	"github.com/charmbracelet/crush/internal/skills"
)

// Reasons the coder agent may be unavailable, returned by
// Workspace.AgentReadyErr so callers can tell a genuinely
// uninitialized agent apart from a lost server connection.
var (
	// ErrAgentNotInitialized means the workspace exists but its coder
	// agent has not been configured/initialized (e.g. no model set).
	ErrAgentNotInitialized = errors.New("coder agent is not initialized")
	// ErrServerUnreachable means the client could not reach the server
	// to determine the agent's status (server down, or the workspace was
	// torn down out from under the client).
	ErrServerUnreachable = errors.New("lost connection to the crush server")
	// ErrWorkspaceGone means the server is reachable but no longer knows
	// this client's workspace: it was torn down, or the server was
	// replaced underneath the client. The subscription loop re-registers
	// the workspace in the background when it sees this.
	ErrWorkspaceGone = errors.New("the server reset this workspace; reconnecting")
	// ErrStreamClosed means an established event stream ended.
	// Resubscribing usually succeeds immediately, but events published in
	// the meantime are lost for good, so the client treats it as a
	// degraded link that requires a resync.
	ErrStreamClosed = errors.New("the event stream closed; reconnecting")
)

// ConnectionState describes the health of the client-server link as
// reported by the [ClientWorkspace] subscription loop.
type ConnectionState int

const (
	// ConnectionDegraded means the event stream is down (or the workspace
	// was lost server-side) and the client is retrying or re-registering
	// in the background.
	ConnectionDegraded ConnectionState = iota
	// ConnectionRecovered means the event stream was re-established,
	// possibly against a re-created workspace.

View on GitHub (pinned to 7944b8e522)

Solutions

  1. Let the subscription loop re-register the workspace automatically; do not abort on this error
  2. If re-registration keeps failing, recreate the workspace and rebind the client
  3. Persist/restore session state so a workspace reset does not lose context
Defensive patterns

Strategy: retry

Type guard

func isWorkspaceGone(err error) bool { return errors.Is(err, workspace.ErrWorkspaceGone) }

Try / catch

if err != nil {
    if errors.Is(err, workspace.ErrWorkspaceGone) {
        // wait for the subscription loop's background re-registration, then retry
        return retryAfterResync(ctx, op)
    }
    return err
}

Prevention

When it happens

Trigger: AgentReadyErr or runSubscription observe the server no longer recognizing the workspace ID after a server-side teardown or replacement.

Common situations: Server restarted with fresh state while a client kept its old workspace handle; another process replaced the workspace; long-lived client outlived the server's session store.

Related errors


AI-assisted analysis of charmbracelet/crush@7944b8e522 (2026-08-29). Data as JSON: /api/errors/d040d6e2d24138bb. Report an issue: GitHub.