JuliusBrussee/caveman · error

native runtime accept

Error message

native runtime accept: %w

What it means

ServeUnix's accept loop returns this error when listener.Accept fails for a reason other than context shutdown. If ctx is done the loop exits cleanly with nil; otherwise the accept failure (e.g. listener closed prematurely, fd exhaustion) is wrapped as "native runtime accept".

Solutions

  1. Raise the open file descriptor limit (ulimit -n / systemd LimitNOFILE)
  2. Check that nothing else closes the listener before ctx cancellation
  3. Inspect for connection leaks in serveConn handlers and restart the runtime process

Example fix

// before
$ ulimit -n 256
$ caveman-runtime serve
// after
$ ulimit -n 4096
$ caveman-runtime serve
Defensive patterns

Strategy: retry

Validate before calling

// raise fd headroom before serving
var lim syscall.Rlimit
syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)
lim.Cur = lim.Max
syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)

Try / catch

err := nativeruntime.ServeUnix(ctx, path, rt)
if err != nil {
	if errors.Is(err, syscall.EMFILE) || strings.Contains(err.Error(), "accept") {
		// back off, free fds, then restart the serve loop
	}
	return err
}

Prevention

When it happens

Trigger: listener.Accept() returns an error while ctx.Err() == nil: the listener was closed by another goroutine, file-descriptor exhaustion (EMFILE), or an OS-level socket error.

Common situations: Too many open files under connection load (ulimit -n); another component calling listener.Close(); resource leaks accumulating open connections in serveConn goroutines.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/153d9788db5f9bc8. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/nativeruntime/server_unix.go:73

	if err != nil {
		return fmt.Errorf("native runtime listen: %w", err)
	}
	defer listener.Close()
	defer os.Remove(path)
	if err := os.Chmod(path, 0o600); err != nil {
		return fmt.Errorf("native runtime chmod socket: %w", err)
	}
	go func() {
		<-ctx.Done()
		_ = listener.Close()
	}()
	for {
		conn, err := listener.Accept()
		if err != nil {
			if ctx.Err() != nil {
				return nil
			}
			return fmt.Errorf("native runtime accept: %w", err)
		}
		go serveConn(ctx, conn, runtime)
	}
}

View on GitHub (pinned to 3ee70a1026)