{"record":{"id":"1a91b9361d4fafb4","repo":"benbjohnson/litestream","slug":"failed-to-read-response-w-1a91b9","errorCode":null,"errorMessage":"failed to read response: %w","messagePattern":"failed to read response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/start.go","lineNumber":71,"sourceCode":"\n\treq := litestream.StartRequest{\n\t\tPath:    dbPath,\n\t\tTimeout: *timeout,\n\t}\n\treqBody, err := json.Marshal(req)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to marshal request: %w\", err)\n\t}\n\n\tresp, err := client.Post(\"http://localhost/start\", \"application/json\", bytes.NewReader(reqBody))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to control socket: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to read response: %w\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tvar errResp litestream.ErrorResponse\n\t\tif err := json.Unmarshal(body, &errResp); err == nil && errResp.Error != \"\" {\n\t\t\treturn fmt.Errorf(\"start failed: %s\", errResp.Error)\n\t\t}\n\t\treturn fmt.Errorf(\"start failed: %s\", string(body))\n\t}\n\n\tvar result litestream.StartResponse\n\tif err := json.Unmarshal(body, &result); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse response: %w\", err)\n\t}\n\n\tconfirmation := StartStopResult{\n\t\tStatus: result.Status,\n\t\tDBPath: result.Path,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/start.go#L53-L89","documentation":"The connection to the daemon's control socket succeeded, but reading the HTTP response body failed via io.ReadAll. Since the body comes from the local Unix-socket HTTP server, this usually means the connection was cut mid-response — daemon crash, timeout cancellation, or a reset connection — rather than a client-side bug.","triggerScenarios":"`litestream start` receives a connection but the daemon closes the connection before the full response is written; the client's -timeout http.Client timeout fires mid-read (context/deadline exceeded); the daemon panics while handling /start and the socket is torn down.","commonSituations":"Daemon restarts under load while the CLI request is in flight; -timeout too small so the client aborts while waiting for a slow start operation; kernel/oom-kills the daemon during the request.","solutions":["Increase -timeout so the client doesn't abort mid-read of a slow /start response","Check daemon logs for a crash or panic around the time of the request","Retry the command; if the daemon is restarting, wait until it is healthy","Ensure the daemon and CLI versions match so response framing is compatible"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check with a cheap request to the socket before the real one:\nresp, err := client.Post(\"http://localhost/status\", \"application/json\", nil)\n_ = resp; _ = err // ensure daemon responds before long-running start","typeGuard":null,"tryCatchPattern":"var netErr net.Error\nif errors.As(err, &netErr) && netErr.Timeout() {\n    // retry with a larger -timeout\n}","preventionTips":["Set -timeout generously relative to how long starting replication can take","Monitor daemon stability (no OOM/crash loops) before scripted starts","Avoid killing/restarting the daemon while CLI commands are in flight"],"tags":["network","ipc","io","cli"],"backgroundTag":"broken-pipe","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}