{"record":{"id":"93d0d05f29e5cb23","repo":"oven-sh/bun","slug":"getrandom-failed-errno-err","errorCode":null,"errorMessage":"getrandom failed: errno {err}","messagePattern":"getrandom failed: errno (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/bun_core/util.rs","lineNumber":2727,"sourceCode":"fn os_entropy(bytes: &mut [u8]) {\n    #[cfg(any(target_os = \"linux\", target_os = \"android\"))]\n    {\n        let mut filled = 0usize;\n        while filled < bytes.len() {\n            // SAFETY: writes at most len-filled bytes into the slice.\n            let rc = unsafe {\n                libc::getrandom(\n                    bytes.as_mut_ptr().add(filled).cast(),\n                    bytes.len() - filled,\n                    0,\n                )\n            };\n            if rc < 0 {\n                let err = crate::ffi::errno();\n                if err == libc::EINTR {\n                    continue;\n                }\n                panic!(\"getrandom failed: errno {err}\");\n            }\n            filled += rc as usize;\n        }\n    }\n    #[cfg(any(target_os = \"macos\", target_os = \"ios\", target_os = \"freebsd\"))]\n    {\n        // getentropy caps at 256 bytes per call.\n        for chunk in bytes.chunks_mut(256) {\n            // SAFETY: chunk is a valid writable slice ≤ 256 bytes.\n            let rc = unsafe { libc::getentropy(chunk.as_mut_ptr().cast(), chunk.len()) };\n            if rc != 0 {\n                panic!(\"getentropy failed\");\n            }\n        }\n    }\n    #[cfg(windows)]\n    {\n        unsafe extern \"system\" {","sourceCodeStart":2709,"sourceCodeEnd":2745,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/bun_core/util.rs#L2709-L2745","documentation":"Panic inside os_entropy() on Linux/Android: the libc getrandom() syscall returned an error other than EINTR (which is retried) while filling the entropy buffer. Because Bun cannot continue safely without OS randomness (needed by hashes, IDs, TLS), the failure aborts the process with the raw errno value embedded.","triggerScenarios":"Thrown at src/bun_core/util.rs:2727 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the reported errno (e.g. EIO, EFAULT) to find the kernel-level cause","Check for seccomp/sandbox restrictions blocking getrandom"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","contentChangedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}