{"record":{"id":"e51c8f72e4f5c04d","repo":"apache/beam","slug":"broken-stream-v-debug-shims","errorCode":null,"errorMessage":"broken stream: %v","messagePattern":"broken stream: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/x/debug/debug.shims.go","lineNumber":365,"sourceCode":"\t\treturn err\n\t}\n\tv.cur = nil\n\treturn nil\n}\n\nfunc iterMakerTypex۰T(s exec.ReStream) exec.ReusableInput {\n\tret := &iterNative{s: s}\n\tret.fn = ret.readTypex۰T\n\treturn ret\n}\n\nfunc (v *iterNative) readTypex۰T(value *beam.T) bool {\n\telm, err := v.cur.Read()\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn false\n\t\t}\n\t\tpanic(fmt.Sprintf(\"broken stream: %v\", err))\n\t}\n\t*value = elm.Elm.(beam.T)\n\treturn true\n}\n\nfunc iterMakerTypex۰XTypex۰Y(s exec.ReStream) exec.ReusableInput {\n\tret := &iterNative{s: s}\n\tret.fn = ret.readTypex۰XTypex۰Y\n\treturn ret\n}\n\nfunc (v *iterNative) readTypex۰XTypex۰Y(key *beam.X, value *beam.Y) bool {\n\telm, err := v.cur.Read()\n\tif err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn false\n\t\t}\n\t\tpanic(fmt.Sprintf(\"broken stream: %v\", err))","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/x/debug/debug.shims.go#L347-L383","documentation":"This panic comes from the generated iterator shim readTypex۰T in the Beam Go SDK debug/x package. It wraps a single-element source whose underlying stream read returned a non-EOF error; because a partially broken stream cannot be recovered inside a DoFn iterator, the shim panics with the underlying cause. It is thrown only when the read error is anything other than io.EOF (which signals normal end of iteration).","triggerScenarios":"Calling v.cur.Read() on the element stream inside a ParDo whose iterator is consumed via range, and the underlying source (e.g. a teststream, data channel, or side input reader) returns an error other than io.EOF — e.g. connection dropped to the runner, corrupted gRPC byte stream, or harness terminated mid-stream.","commonSituations":"Runner (Flink/Spark/Dataflow) worker connection drops during a streaming job; a TestStream or debug source feeding x/debug shims fails mid-iteration; network partitions between harness and runner causing the element reader to return a transport error.","solutions":["Inspect the wrapped %v cause in the panic message to identify the transport/source failure (usually a gRPC or connection error).","Check runner worker logs for harness/runner disconnections and fix network stability or increase timeouts.","Retry the pipeline; for streaming jobs configure runner-level restart/checkpointing so a broken channel recovers.","If reproducible locally, run with a stable direct runner or fixed TestStream data to isolate whether the source or the network is at fault."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go panics cannot be caught by error returns; wrap the DoFn body if you must contain it:\nfunc safeRead(v *iterNative, value *beam.T) (ok bool) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"stream read failed: %v\", r)\n            ok = false\n        }\n    }()\n    return v.readTypex۰T(value)\n}","preventionTips":["Monitor runner worker connectivity and set generous gRPC timeouts for streaming jobs.","Enable runner checkpointing/restarts so broken channels recover automatically.","Reproduce with TestStream or the direct runner before deploying to a distributed runner."],"tags":["go","apache-beam","stream","panic"],"backgroundTag":"broken-pipe","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}