Skip to content

Mark undelivered Channel items on cancellation without erasing prior errors #89

Description

@MasterOfBinary

Current outcome

Keep the successfully delivered prefix distinct from the undelivered remainder when a channel sink is canceled.

Replanned on 2026-09-06 against GoBatch master 63ef757 and ShitQuant's recorder, enrichment, paper/replay, and flow workloads. This is an implementation target, not a claim that the behavior already exists.

Required behavior

Verification and completion

Cancel after one synchronized send to a controlled/unbuffered consumer; assert exactly which items arrived and each remaining item's status/cause. Include a prior-error item.

Follow the repository's formatting, race-test, vet/lint, package documentation, example and changelog requirements for the changed surface. Report the actual supported behavior and migration; do not treat a passing coverage percentage as proof of these outcomes.

Scope and relationships

Precise bug remains useful independently. Coordinate lifecycle and #79, without making a future flow package a prerequisite.

Design history

The earlier report/prototype remains below for provenance; the requirements above supersede conflicting prescriptions. Existing discussion is preserved.

Original issue: processor.Channel reports undelivered items as successful on context cancel

When the context is canceled mid-batch, processor.Channel.Process returns immediately with the remaining unsent items untouched (processor/channel.go:30-34):

select {
case <-ctx.Done():
    return items, ctx.Err()
case p.Output <- item.Data:
}

The stage error becomes a single ProcessorError, but every item that never reached Output comes back with Error == nil — per-item accounting says "delivered" for data that was never sent.

Repro sketch: unbuffered Output with a slow consumer, cancel the context after the first send; items 2..N are reported as processed successfully.

Suggested fix: mark undelivered items with ctx.Err() before returning (same pattern as processor.Nil's MarkCancelled), so downstream error accounting reflects reality.

Found in the 2026-07-10 full-repo review (verified by repro).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions