{"record":{"id":"60d214127609ac43","repo":"wavetermdev/waveterm","slug":"error-checking-connection-status-w","errorCode":null,"errorMessage":"error checking connection status: %w","messagePattern":"error checking connection status: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/jobcontroller/jobcontroller.go","lineNumber":589,"sourceCode":"\tdefer jobControllerLock.Unlock()\n\tcount := 0\n\tfor _, status := range jobConnStates {\n\t\tif status == JobConnStatus_Connected {\n\t\t\tcount++\n\t\t}\n\t}\n\treturn count\n}\n\nfunc CheckJobConnected(ctx context.Context, jobId string) (*waveobj.Job, error) {\n\tjob, err := wstore.DBMustGet[*waveobj.Job](ctx, jobId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get job: %w\", err)\n\t}\n\n\tisConnected, err := conncontroller.IsConnected(job.Connection)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error checking connection status: %w\", err)\n\t}\n\tif !isConnected {\n\t\treturn nil, fmt.Errorf(\"connection %q is not connected\", job.Connection)\n\t}\n\n\tjobConnStatus := GetJobConnStatus(jobId)\n\tif jobConnStatus != JobConnStatus_Connected {\n\t\treturn nil, fmt.Errorf(\"job is not connected (status: %s)\", jobConnStatus)\n\t}\n\n\treturn job, nil\n}\n\ntype StartJobParams struct {\n\tConnName string\n\tJobKind  string\n\tCmd      string\n\tArgs     []string","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/jobcontroller/jobcontroller.go#L571-L607","documentation":"After loading the job, CheckJobConnected calls conncontroller.IsConnected on the job's connection. This error wraps any failure from that connectivity probe itself (as opposed to a definitive 'not connected' answer).","triggerScenarios":"conncontroller.IsConnected fails while checking job.Connection — unknown connection name, SSH config resolution failure, or internal router error.","commonSituations":"Connection removed from config while a job still references it; malformed SSH connection name; domain/socket router not yet started.","solutions":["Inspect the wrapped error to see why IsConnected failed","Verify job.Connection names an existing configured connection","Wait/retry if the connection router is still initializing","Remove or reassign stale connections on the job"],"exampleFix":"// before\njob, err := jobcontroller.CheckJobConnected(ctx, jobId)\nif err != nil {\n\treturn err\n}\n// after\njob, err := jobcontroller.CheckJobConnected(ctx, jobId)\nif err != nil {\n\tif strings.Contains(err.Error(), \"error checking connection status\") {\n\t\treturn retryLater // transient connectivity check failure\n\t}\n\treturn err\n}","handlingStrategy":"retry","validationCode":"connName := job.Connection\nif _, ok := connRegistry[connName]; !ok {\n\treturn fmt.Errorf(\"connection %s is not configured\", connName)\n}","typeGuard":"func isConnCheckErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"error checking connection status\")\n}","tryCatchPattern":"job, err := jobcontroller.CheckJobConnected(ctx, jobId)\nif isConnCheckErr(err) {\n\ttime.Sleep(500 * time.Millisecond)\n\tjob, err = jobcontroller.CheckJobConnected(ctx, jobId)\n}\nif err != nil { return err }","preventionTips":["Keep job.Connection values in sync with the connection config","Clean up jobs when their connection is removed","Retry transient check failures with backoff","Ensure the connection router is initialized before probing"],"tags":["network","connection","job-controller"],"backgroundTag":"connection-status-check-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}