{"record":{"id":"d040d6e2d24138bb","repo":"charmbracelet/crush","slug":"the-server-reset-this-workspace-reconnecting","errorCode":null,"errorMessage":"the server reset this workspace; reconnecting","messagePattern":"the server reset this workspace; reconnecting","errorType":"exception","errorClass":"ErrWorkspaceGone","httpStatus":null,"severity":"warning","filePath":"internal/workspace/workspace.go","lineNumber":43,"sourceCode":"\t\"github.com/charmbracelet/crush/internal/skills\"\n)\n\n// Reasons the coder agent may be unavailable, returned by\n// Workspace.AgentReadyErr so callers can tell a genuinely\n// uninitialized agent apart from a lost server connection.\nvar (\n\t// ErrAgentNotInitialized means the workspace exists but its coder\n\t// agent has not been configured/initialized (e.g. no model set).\n\tErrAgentNotInitialized = errors.New(\"coder agent is not initialized\")\n\t// ErrServerUnreachable means the client could not reach the server\n\t// to determine the agent's status (server down, or the workspace was\n\t// torn down out from under the client).\n\tErrServerUnreachable = errors.New(\"lost connection to the crush server\")\n\t// ErrWorkspaceGone means the server is reachable but no longer knows\n\t// this client's workspace: it was torn down, or the server was\n\t// replaced underneath the client. The subscription loop re-registers\n\t// the workspace in the background when it sees this.\n\tErrWorkspaceGone = errors.New(\"the server reset this workspace; reconnecting\")\n\t// ErrStreamClosed means an established event stream ended.\n\t// Resubscribing usually succeeds immediately, but events published in\n\t// the meantime are lost for good, so the client treats it as a\n\t// degraded link that requires a resync.\n\tErrStreamClosed = errors.New(\"the event stream closed; reconnecting\")\n)\n\n// ConnectionState describes the health of the client-server link as\n// reported by the [ClientWorkspace] subscription loop.\ntype ConnectionState int\n\nconst (\n\t// ConnectionDegraded means the event stream is down (or the workspace\n\t// was lost server-side) and the client is retrying or re-registering\n\t// in the background.\n\tConnectionDegraded ConnectionState = iota\n\t// ConnectionRecovered means the event stream was re-established,\n\t// possibly against a re-created workspace.","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/workspace/workspace.go#L25-L61","documentation":"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.","triggerScenarios":"AgentReadyErr or runSubscription observe the server no longer recognizing the workspace ID after a server-side teardown or replacement.","commonSituations":"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.","solutions":["Let the subscription loop re-register the workspace automatically; do not abort on this error","If re-registration keeps failing, recreate the workspace and rebind the client","Persist/restore session state so a workspace reset does not lose context"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isWorkspaceGone(err error) bool { return errors.Is(err, workspace.ErrWorkspaceGone) }","tryCatchPattern":"if err != nil {\n    if errors.Is(err, workspace.ErrWorkspaceGone) {\n        // wait for the subscription loop's background re-registration, then retry\n        return retryAfterResync(ctx, op)\n    }\n    return err\n}","preventionTips":["Rely on the subscription loop's automatic re-registration instead of failing fast","Keep session IDs stable across server restarts where possible","Log this error at info level — it is expected during server resets"],"tags":["workspace","state-sync","reconnect"],"backgroundTag":"workspace-gone","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}