JuliusBrussee/caveman · error
native runtime accept: %w
Error message
native runtime accept: %w
What it means
Returned when listener.Accept() fails in the native runtime's Unix serve loop and the context is still alive. A normal shutdown path exists (ctx cancelled closes the listener and Accept returns nil), so this error means an unexpected accept failure: file-descriptor exhaustion, socket closed out from under the loop, or resource limits.
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 27d5a3981a)
Solutions
- Check the process fd usage (ls /proc/<pid>/fd | wc -l) against ulimit -n and raise the limit or fix a leak
- Verify nothing external is closing or unlinking the socket (other scripts, container supervisors)
- Apply an accept backoff: on transient errors like EMFILE, sleep briefly and continue instead of returning
- Restart Serve with a fresh context after the environment is corrected
Example fix
// before: any accept error other than ctx-cancel kills the server
conn, err := listener.Accept()
if err != nil {
if ctx.Err() != nil { return nil }
return fmt.Errorf("native runtime accept: %w", err)
}
// after: tolerate transient accept errors
conn, err := listener.Accept()
if err != nil {
if ctx.Err() != nil { return nil }
if isTemporaryAcceptError(err) { time.Sleep(50 * time.Millisecond); continue }
return fmt.Errorf("native runtime accept: %w", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Raise the fd ceiling before serving (best effort)
var rl syscall.Rlimit
if syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rl) == nil && rl.Cur < 4096 {
rl.Cur = 4096
_ = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rl)
} Try / catch
err := nativeruntime.Serve(ctx, home, rt)
var oe *net.OpError
if errors.As(err, &oe) && strings.Contains(err.Error(), "native runtime accept") {
if errors.Is(oe.Err, syscall.EMFILE) || errors.Is(oe.Err, syscall.ENFILE) {
// fd exhaustion: shed load, raise limit, restart serve loop
}
} Prevention
- Monitor open-fd count against ulimit in long-running deployments
- Close per-connection resources deterministically in serveConn
- Run Serve under a supervisor that restarts it if accept fails unexpectedly
When it happens
Trigger: Long-running Serve where the process hits its FD limit (ulimit -n) so accept(2) returns EMFILE, or an external process unlinks/closes the listening socket, or the listener is closed by anything other than the ctx-done goroutine.
Common situations: Leaked per-connection goroutines/files pushing the process over the fd ceiling on a busy machine; systemd socket activation or a supervisor interfering with the socket; container environments with low default RLIMIT_NOFILE.
Related errors
- native runtime: socket already active
- native runtime listen: %w
- native runtime named-pipe accept: %w
- cachebench: nil corpus reader
- message exceeds byte limit
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/153d9788db5f9bc8.
Report an issue: GitHub.