{"record":{"id":"a53672b116c427af","repo":"geektutu/7days-golang","slug":"reading-body-a53672","errorCode":null,"errorMessage":"reading body ","messagePattern":"reading body ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gee-rpc/day3-service/client.go","lineNumber":152,"sourceCode":"\tfor err == nil {\n\t\tvar h codec.Header\n\t\tif err = client.cc.ReadHeader(&h); err != nil {\n\t\t\tbreak\n\t\t}\n\t\tcall := client.removeCall(h.Seq)\n\t\tswitch {\n\t\tcase call == nil:\n\t\t\t// it usually means that Write partially failed\n\t\t\t// and call was already removed.\n\t\t\terr = client.cc.ReadBody(nil)\n\t\tcase h.Error != \"\":\n\t\t\tcall.Error = fmt.Errorf(h.Error)\n\t\t\terr = client.cc.ReadBody(nil)\n\t\t\tcall.done()\n\t\tdefault:\n\t\t\terr = client.cc.ReadBody(call.Reply)\n\t\t\tif err != nil {\n\t\t\t\tcall.Error = errors.New(\"reading body \" + err.Error())\n\t\t\t}\n\t\t\tcall.done()\n\t\t}\n\t}\n\t// error occurs, so terminateCalls pending calls\n\tclient.terminateCalls(err)\n}\n\n// Go invokes the function asynchronously.\n// It returns the Call structure representing the invocation.\nfunc (client *Client) Go(serviceMethod string, args, reply interface{}, done chan *Call) *Call {\n\tif done == nil {\n\t\tdone = make(chan *Call, 10)\n\t} else if cap(done) == 0 {\n\t\tlog.Panic(\"rpc client: done channel is unbuffered\")\n\t}\n\tcall := &Call{\n\t\tServiceMethod: serviceMethod,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/geektutu/7days-golang/blob/cf3644382101dc13e7fd92e8f5c66cabc51bcd3b/gee-rpc/day3-service/client.go#L134-L170","documentation":"Error built in the client's receive loop when ReadBody fails while decoding the response body into the call's Reply value. The RPC completed on the server side but the reply could not be deserialized (codec mismatch, corrupt/truncated body, or incompatible reply type), so the call fails with \"reading body \" + the underlying codec error.","triggerScenarios":"Thrown at gee-rpc/day3-service/client.go:152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the reply argument type matches the type the server encodes for that method.","Use the same codec (and codec version) on both client and server via Option.CodecType.","Log the wrapped underlying error; a truncated body often indicates a network disconnect — retry the call on a new connection."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"cf3644382101dc13e7fd92e8f5c66cabc51bcd3b","analyzedAt":"2026-09-03T18:31:24.087Z","contentChangedAt":"2026-09-03T18:31:24.087Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}