{"record":{"id":"b13961a251c4a80c","repo":"gravitational/teleport","slug":"xsession-was-terminated","errorCode":null,"errorMessage":"xsession was terminated","messagePattern":"xsession was terminated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/srv/desktop/linux_server.go","lineNumber":815,"sourceCode":"\t\tAuthorityFile:  sess.backend.AuthorityFile,\n\t})\n\tif err != nil {\n\t\treturn trace.Wrap(err, \"Couldn't start Xsession\")\n\t}\n\tsess.cmd = cmd\n\tsess.errGroup.Go(func() error {\n\t\terrCh := make(chan error, 1)\n\t\tgo func() {\n\t\t\terrCh <- cmd.Wait()\n\t\t}()\n\t\tselect {\n\t\tcase <-sess.ctx.Done():\n\t\t\treturn nil\n\t\tcase err := <-errCh:\n\t\t\tif err != nil {\n\t\t\t\treturn trace.Wrap(err, \"xsession was terminated with error\")\n\t\t\t}\n\t\t\treturn trace.Wrap(errors.New(\"xsession was terminated\"))\n\t\t}\n\t})\n\treturn nil\n}\n\nfunc (sess *linuxSession) handleClientScreenSpec(m *tdpb.ClientScreenSpec) error {\n\tif m.Width > types.MaxRDPScreenWidth || m.Height > types.MaxRDPScreenHeight {\n\t\treturn trace.BadParameter(\"invalid screen size %dx%d, maximum is %dx%d\", m.Width, m.Height, types.MaxRDPScreenWidth, types.MaxRDPScreenHeight)\n\t}\n\tsess.resizeMu.Lock()\n\tdefer sess.resizeMu.Unlock()\n\twidth := uint16(m.Width)\n\theight := uint16(m.Height)\n\tsess.screenSize.Width = width\n\tsess.screenSize.Height = height\n\tsess.sendFullScreen = true\n\tif err := sess.backend.Resize(width, height); err != nil {\n\t\treturn trace.Wrap(err, \"Couldn't resize backend\")","sourceCodeStart":797,"sourceCodeEnd":833,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/srv/desktop/linux_server.go#L797-L833","documentation":"In lib/srv/desktop/linux_server.go the desktop session supervises an xsession (Xorg/Xvfb process). When the xsession's error channel yields a nil error while the session goroutine ends, the watcher returns 'xsession was terminated', meaning the X server process exited without reporting a specific error.","triggerScenarios":"The X server process backing the desktop session exits (crash, SIGKILL, OOM kill, or clean exit) and its error channel closes with no error; the select in the session waiter converts that into this wrapped trace error.","commonSituations":"Linux desktop access sessions where Xorg crashes due to a bad driver/mode, the host is under memory pressure (OOM killer terminates Xvfb/Xorg), or the session is forcibly terminated by an admin.","solutions":["Check systemd/journal logs for the Xorg/Xvfb process crash reason","Verify display server binaries and GPU/dummy drivers are installed and compatible","Check dmesg for OOM kills and add memory or limit concurrent desktop sessions","Have the user reconnect — a new session typically starts a fresh xsession"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify the X server binary exists and host has memory before starting a session\nif _, err := exec.LookPath(\"Xorg\"); err != nil {\n  return fmt.Errorf(\"display server missing: %w\", err)\n}\nif avail := memAvailable(); avail < minDesktopSessionMem {\n  return fmt.Errorf(\"insufficient memory for desktop session\")\n}","typeGuard":null,"tryCatchPattern":"err := attachDesktopSession(ctx, sessionID)\nif isXsessionTerminated(err) {\n  log.Printf(\"xsession died without error; check journalctl for Xorg crash\")\n  return retrySession(ctx, sessionID)\n}","preventionTips":["Monitor host memory to prevent OOM kills of Xorg/Xvfb","Install correct GPU/dummy drivers for headless desktop access","Alert on frequent desktop session termination events"],"tags":["teleport","desktop-access","xsession","process-crash"],"backgroundTag":"display-server-terminated","analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}