Skip to content

memoryTransport.Recv dead branch on closed input channel #131

@nficano

Description

@nficano

Category: bug Severity: minor
Location: transport/memory.go:52-64

What

The in channel is never closed anywhere (NewMemoryPair only closes the shared closed signal). The !ok branch is therefore unreachable, and a reader of an out-of-band closed in channel would actually hot-loop on a never-blocking receive — minor latent foot-gun if the chan is ever closed elsewhere later.

Evidence

func (t *memoryTransport) Recv(ctx context.Context) (arcp.Envelope, error) {
	select {
	case env, ok := <-t.in:
		if !ok { return arcp.Envelope{}, ErrClosed }
		return env, nil
	case <-t.closed: return arcp.Envelope{}, ErrClosed
	case <-ctx.Done(): return arcp.Envelope{}, ctx.Err()
	}
}

Proposed fix

Either delete the !ok branch (it is dead) or close in/out on closer() and drop the separate closed channel.

Acceptance criteria

  • Dead branch removed or made reachable by a single source of close truth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions