oven-sh/bun · error

Cast bun.FD.uv( ) makes closing impossible! The supplier of…

Error message

Cast bun.FD.uv({}) makes closing impossible!

The supplier of fd FD should call 'FD.makeLibUVOwned', probably where open() was called.

What it means

Panic guard in bun.FD's libuv-handle conversion: the fd was not marked libuv-owned (FD.makeLibUVOwned not called where it was opened), so casting it to a uv handle would produce a handle that can never be closed correctly; the panic names the fd supplier at fault.

Solutions

  1. Call FD.makeLibUVOwned at the site where the fd is opened
  2. Audit fd creation paths to ensure ownership is recorded before uv conversion
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/bun_core/util.rs:1008 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/3fe5d748502ed76e. Report an issue: GitHub.

Appendix: source

Thrown at src/bun_core/util.rs:1008

                if Some(self) == fd::WINDOWS_CACHED_STDIN.get().copied() {
                    return 0;
                }
                if Some(self) == fd::WINDOWS_CACHED_STDOUT.get().copied() {
                    return 1;
                }
                if Some(self) == fd::WINDOWS_CACHED_STDERR.get().copied() {
                    return 2;
                }
                if fd::is_stdio_handle(fd::STD_INPUT_HANDLE, handle) {
                    return 0;
                }
                if fd::is_stdio_handle(fd::STD_OUTPUT_HANDLE, handle) {
                    return 1;
                }
                if fd::is_stdio_handle(fd::STD_ERROR_HANDLE, handle) {
                    return 2;
                }
                panic!(
                    "Cast bun.FD.uv({}) makes closing impossible!\n\n\
                     The supplier of fd FD should call 'FD.makeLibUVOwned',\n\
                     probably where open() was called.",
                    self,
                );
            }
        }
    }

    #[cfg(not(windows))]
    #[inline]
    pub const fn stdin() -> Fd {
        Fd(0)
    }
    #[cfg(not(windows))]
    #[inline]
    pub const fn stdout() -> Fd {
        Fd(1)

View on GitHub (pinned to 8c5296ac45)