{"record":{"id":"5e6ce6324be71422","repo":"hashicorp/nomad","slug":"error-following-logs-s","errorCode":null,"errorMessage":"error following logs: %s","messagePattern":"error following logs: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/alloc_logs.go","lineNumber":310,"sourceCode":"\t\t} else {\n\t\t\tl.numLines = defaultTailLines\n\t\t}\n\n\t\tr, readErr = l.followFile(client, alloc, logType, api.OriginEnd, offset)\n\n\t\t// If numLines is set, wrap the reader\n\t\tif l.numLines != -1 {\n\t\t\tr = NewLineLimitReader(r, int(l.numLines), int(l.numLines*bytesToLines), 1*time.Second)\n\t\t}\n\n\t\tif readErr != nil {\n\t\t\treturn fmt.Errorf(\"error tailing file: %v\", readErr)\n\t\t}\n\t}\n\n\tdefer r.Close()\n\tif _, err := io.Copy(os.Stdout, r); err != nil {\n\t\treturn fmt.Errorf(\"error following logs: %s\", err)\n\t}\n\n\treturn nil\n}\n\n// followFile outputs the contents of the file to stdout relative to the end of\n// the file.\nfunc (l *AllocLogsCommand) followFile(client *api.Client, alloc *api.Allocation,\n\tlogType, origin string, offset int64) (io.ReadCloser, error) {\n\n\tcancel := make(chan struct{})\n\tframes, errCh := client.AllocFS().Logs(alloc, l.follow, l.task, logType, origin, offset, cancel, nil)\n\n\t// Setting up the logs stream can fail, therefore we need to check the\n\t// error channel before continuing further.\n\tselect {\n\tcase err := <-errCh:\n\t\treturn nil, err","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/alloc_logs.go#L292-L328","documentation":"Raised after the log reader is successfully opened, when io.Copy(os.Stdout, r) fails while streaming log contents to the terminal - the stream broke mid-read (client disconnect, allocation stopped, network error).","triggerScenarios":"Thrown at command/alloc_logs.go:310 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network stability between CLI and the Nomad client","Confirm the allocation/task did not stop during streaming","Re-run the command to restart the log stream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}