{"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":"Error \"getrandom failed: errno {err}\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/bun_core/util.rs:2727 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}