oven-sh/bun · error
getrandom failed: errno
Error message
getrandom failed: errno {err} What it means
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.
Solutions
- Inspect the reported errno (e.g. EIO, EFAULT) to find the kernel-level cause
- Check for seccomp/sandbox restrictions blocking getrandom
Defensive patterns
Strategy: retry
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.
Appendix: 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)