gastownhall/beads · error

proxy: unexpected data listener address %T

Error message

proxy: unexpected data listener address %T

What it means

A defensive invariant check: after net.Listen succeeds, ListenAndServe asserts the listener's address is a *net.TCPAddr so it can extract the actual bound port. If the Go runtime ever returns a non-TCP address for a tcp listener, this error aborts startup. It essentially never fires in practice.

Source

Thrown at internal/storage/dbproxy/proxy/server.go:235

		p.stats.IncBackendStop()
		releaseLock()
		_ = stopBackendBounded(p.server)
		return fmt.Errorf("%w for %s: stop epoch advanced during startup", errStartInterrupted, p.rootDir)
	}

	addr := fmt.Sprintf("127.0.0.1:%d", p.port)

	ln, err := net.Listen("tcp", addr)
	if err != nil {
		return fmt.Errorf("listen on %s: %w", addr, err)
	}

	p.listener = ln
	defer func() { _ = ln.Close() }()
	p.stats.IncListenAndServe()
	dataPort, ok := ln.Addr().(*net.TCPAddr)
	if !ok {
		return fmt.Errorf("proxy: unexpected data listener address %T", ln.Addr())
	}

	if _, err := identity.WriteSecret(p.rootDir); err != nil {
		return fmt.Errorf("write proxy secret: %w", err)
	}

	var identMu sync.RWMutex
	identReply := identity.IdentReply{
		Schema:   pidfile.SchemaV2,
		Role:     pidfile.KindProxy,
		DataPort: dataPort.Port,
	}
	control, err := startControl(p.rootDir, func() identity.IdentReply {
		identMu.RLock()
		defer identMu.RUnlock()
		return identReply
	})
	if err != nil {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Confirm no local modifications changed the listen network away from "tcp"
  2. If running a patched Go runtime or network interceptor, verify ln.Addr() returns *net.TCPAddr
  3. Report as a bug with the %T type shown in the message
Defensive patterns

Strategy: type-guard

Validate before calling

ln, err := net.Listen("tcp", addr)
if _, ok := ln.Addr().(*net.TCPAddr); !ok {
    return fmt.Errorf("listener addr not TCP: %T", ln.Addr())
}

Type guard

func isTCPAddr(a net.Addr) bool { _, ok := a.(*net.TCPAddr); return ok }

Prevention

When it happens

Trigger: Only when ln.Addr() does not type-assert to *net.TCPAddr despite the listener being created with network "tcp" - an internal invariant violation, not a user-facing condition.

Common situations: Effectively only seen if the code was modified (e.g. listen network changed to "unix") or a custom/monkey-patched net stack is in use during testing.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/cc93c5514bda7c7c. Report an issue: GitHub.