{"record":{"id":"153d9788db5f9bc8","repo":"JuliusBrussee/caveman","slug":"native-runtime-accept-w","errorCode":null,"errorMessage":"native runtime accept: %w","messagePattern":"native runtime accept: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/server_unix.go","lineNumber":73,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"native runtime listen: %w\", err)\n\t}\n\tdefer listener.Close()\n\tdefer os.Remove(path)\n\tif err := os.Chmod(path, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod socket: %w\", err)\n\t}\n\tgo func() {\n\t\t<-ctx.Done()\n\t\t_ = listener.Close()\n\t}()\n\tfor {\n\t\tconn, err := listener.Accept()\n\t\tif err != nil {\n\t\t\tif ctx.Err() != nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"native runtime accept: %w\", err)\n\t\t}\n\t\tgo serveConn(ctx, conn, runtime)\n\t}\n}\n","sourceCodeStart":55,"sourceCodeEnd":78,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/server_unix.go#L55-L78","documentation":"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\".","triggerScenarios":"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.","commonSituations":"Too many open files under connection load (ulimit -n); another component calling listener.Close(); resource leaks accumulating open connections in serveConn goroutines.","solutions":["Raise the open file descriptor limit (ulimit -n / systemd LimitNOFILE)","Check that nothing else closes the listener before ctx cancellation","Inspect for connection leaks in serveConn handlers and restart the runtime process"],"exampleFix":"// before\n$ ulimit -n 256\n$ caveman-runtime serve\n// after\n$ ulimit -n 4096\n$ caveman-runtime serve","handlingStrategy":"retry","validationCode":"// raise fd headroom before serving\nvar lim syscall.Rlimit\nsyscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim)\nlim.Cur = lim.Max\nsyscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)","typeGuard":null,"tryCatchPattern":"err := nativeruntime.ServeUnix(ctx, path, rt)\nif err != nil {\n\tif errors.Is(err, syscall.EMFILE) || strings.Contains(err.Error(), \"accept\") {\n\t\t// back off, free fds, then restart the serve loop\n\t}\n\treturn err\n}","preventionTips":["Raise RLIMIT_NOFILE for long-running runtimes","Ensure serveConn goroutines always close their connections","Never close the listener outside the ctx.Done path"],"tags":["network","socket","accept","fd-limit"],"backgroundTag":"broken-pipe","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}