{"record":{"id":"474e714e8b601809","repo":"crowdsecurity/crowdsec","slug":"cannot-read-line-in-response-w","errorCode":null,"errorMessage":"cannot read line in response: %w","messagePattern":"cannot read line in response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/victorialogs/internal/vlclient/vl_client.go","lineNumber":210,"sourceCode":"\t\tcase <-ctx.Done():\n\t\t\treturn n, latestTS, nil\n\t\tdefault:\n\t\t}\n\n\t\tb, err := br.ReadBytes('\\n')\n\t\tif err != nil {\n\t\t\tif errors.Is(err, bufio.ErrBufferFull) {\n\t\t\t\tlc.Logger.Infof(\"skipping line number #%d: line too long\", n)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\t// b can be != nil when EOF is returned, so we need to process it\n\t\t\t\tfinishedReading = true\n\t\t\t} else if errors.Is(err, context.Canceled) {\n\t\t\t\treturn n, latestTS, nil\n\t\t\t} else {\n\t\t\t\treturn n, latestTS, fmt.Errorf(\"cannot read line in response: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tif len(b) == 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\tb = bytes.Trim(b, \"\\n\")\n\n\t\tvar logLine Log\n\n\t\tif err := json.Unmarshal(b, &logLine); err != nil {\n\t\t\tlc.Logger.Warnf(\"cannot unmarshal line in response: %s\", string(b))\n\t\t\tcontinue\n\t\t}\n\n\t\tn++\n","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/victorialogs/internal/vlclient/vl_client.go#L192-L228","documentation":"readResponse reads the streaming newline-delimited JSON body line by line with a JSON decoder/reader. When a read fails for a reason other than EOF or context cancellation (connection reset, unexpected short read, I/O error), the error is wrapped with \"cannot read line in response\" and returned to doQueryRange.","triggerScenarios":"The response body reader returns a non-EOF, non-canceled error mid-stream — e.g. the HTTP connection is reset by VictoriaLogs or a proxy while the acquisition is still reading.","commonSituations":"Large result sets taking long enough for an idle timeout/load balancer to kill the connection, VictoriaLogs restarting mid-query, proxy or keep-alive misconfiguration dropping long-lived streaming responses.","solutions":["Check the wrapped inner error for the root cause (connection reset, unexpected EOF, timeout)","Reduce the `limit` in the DSN so responses complete faster and are less likely to be dropped","Check intermediate proxies/load balancers idle timeouts for long streaming responses","Ensure VictoriaLogs is stable and not restarting during queries"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await runAcquisition()\n} catch (e) {\n  if (String(e).includes(\"cannot read line in response\")) {\n    log.warn(\"Stream dropped, restarting acquisition\", e.message)\n    scheduleRestart()\n  } else { throw e }\n}","preventionTips":["Lower `limit` so streaming responses finish before idle timeouts","Raise proxy/LB idle timeouts for long-lived streaming HTTP","Ensure VictoriaLogs is not restarted or OOM-killed during queries"],"tags":["network","io","victorialogs"],"backgroundTag":"broken-pipe","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}