oven-sh/bun · error

getrandom failed: errno {err}

Error message

getrandom failed: errno {err}

What it means

Error "getrandom failed: errno {err}" thrown in oven-sh/bun.

Source

Thrown at src/bun_core/util.rs:2727

fn os_entropy(bytes: &mut [u8]) {
    #[cfg(any(target_os = "linux", target_os = "android"))]
    {
        let mut filled = 0usize;
        while filled < bytes.len() {
            // SAFETY: writes at most len-filled bytes into the slice.
            let rc = unsafe {
                libc::getrandom(
                    bytes.as_mut_ptr().add(filled).cast(),
                    bytes.len() - filled,
                    0,
                )
            };
            if rc < 0 {
                let err = crate::ffi::errno();
                if err == libc::EINTR {
                    continue;
                }
                panic!("getrandom failed: errno {err}");
            }
            filled += rc as usize;
        }
    }
    #[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]
    {
        // getentropy caps at 256 bytes per call.
        for chunk in bytes.chunks_mut(256) {
            // SAFETY: chunk is a valid writable slice ≤ 256 bytes.
            let rc = unsafe { libc::getentropy(chunk.as_mut_ptr().cast(), chunk.len()) };
            if rc != 0 {
                panic!("getentropy failed");
            }
        }
    }
    #[cfg(windows)]
    {
        unsafe extern "system" {

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/bun_core/util.rs:2727 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/93d0d05f29e5cb23. Report an issue: GitHub.