apache/beam · critical

broken stream

Error message

broken stream

What it means

invoke reads the next element from the reusable re-iterator backing a DoFn's main input; io.EOF means the iteration is done (returns false), but any other read failure is fatal and is paniced as 'broken stream'. The runtime deliberately panics because a broken reader means the bundle cannot continue producing correct results.

Source

Thrown at sdks/go/pkg/beam/core/runtime/exec/input.go:163

		panic("Init() not called")
	}
	if err := v.cur.Close(); err != nil {
		return err
	}
	v.cur = nil
	return nil
}

func (v *iterValue) invoke(args []reflect.Value) []reflect.Value {
	if v.cur == nil {
		panic("Init() not called")
	}
	elm, err := v.cur.Read()
	if err != nil {
		if err == io.EOF {
			return []reflect.Value{reflect.ValueOf(false)}
		}
		panic(errors.Wrap(err, "broken stream"))
	}

	// We expect 1-3 out parameters: func (*int, *string) bool.

	isKey := true
	for i, t := range v.types {
		var v reflect.Value
		switch {
		case isKey:
			v = reflect.ValueOf(Convert(elm.Elm, t))
			isKey = false
		default:
			v = reflect.ValueOf(Convert(elm.Elm2, t))
		}
		args[i].Elem().Set(v)
	}
	return []reflect.Value{reflect.ValueOf(true)}
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Let the runner retry the bundle; look at the wrapped cause in the panic chain for the root transport or decode error.
  2. Check runner-to-worker connectivity and data-plane health.
  3. If caused by a decode mismatch, fix the coder/element type alignment feeding this DoFn.
  4. Inspect whether user code closed or consumed the iterator concurrently.
Defensive patterns

Strategy: retry

Try / catch

// user code wrapping the iterator should not swallow non-EOF errors
for {
    v, err := iter.Read()
    if err == io.EOF { break }
    if err != nil { return fmt.Errorf("broken stream: %w", err) /* let runner retry */ }
}

Prevention

When it happens

Trigger: invoke() on a reusableReader where v.cur.Read() returns a non-EOF error: the side data plane stream delivering elements failed mid-iteration (transport error, decode corruption, closed reader).

Common situations: Network failure between runner and worker during element delivery; an upstream decode error (e.g. 4995/4996) wrapped and re-paniced here; bundle cancellation closing the stream unexpectedly.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/ea569a9c49456bf7. Report an issue: GitHub.