oven-sh/bun · error

Unexpected error while reloading process

Error message

Unexpected error while reloading process

What it means

On Windows the hot-reload watcher restart is performed by terminating the current process with the magic exit code 0xC031EF32, which the watcher-manager matches to relaunch it. If TerminateProcess on our own process returns 0, the process could not be terminated, so the reload never happens. The error reports the Win32 GetLastError code, not an errno.

Solutions

  1. Check the reported Win32 error code for the underlying OS failure (e.g. access denied when terminating the process)
  2. Retry the reload, or fall back to a full manual restart of `bun --watch`
  3. Verify no security software or job-object policy is blocking TerminateProcess on the current process
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/bun_core/util.rs:4440 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/81ac9c82d10fb29d. Report an issue: GitHub.

Appendix: source

Thrown at src/bun_core/util.rs:4440

            safe fn TerminateProcess(h: *mut core::ffi::c_void, code: u32) -> i32;
        }
        // = 3224497970. Parent
        // watcher-manager compares the child's exit code against exactly this.
        const WATCHER_RELOAD_EXIT: u32 = 0xC031_EF32;
        let rc = TerminateProcess(GetCurrentProcess(), WATCHER_RELOAD_EXIT);
        if rc == 0 {
            let err = GetLastError();
            if may_return {
                crate::output::err_generic("Failed to reload process: {}", (err,));
                return;
            }
            panic!("Error while reloading process: {}", err);
        } else {
            if may_return {
                crate::output::err_generic("Failed to reload process", ());
                return;
            }
            panic!("Unexpected error while reloading process\n");
        }
    }

    #[cfg(unix)]
    // SAFETY: FFI calls receive only locally-built NUL-terminated argv/envp arrays; on success
    // `execve` never returns, on failure errno is read. No borrowed Rust state observed after.
    unsafe {
        {
            unsafe extern "C" {
                safe fn on_before_reload_process_posix();
            }
            on_before_reload_process_posix();
        }

        // We clone argv so that the memory address isn't the same as the libc one.
        let args = argv_storage();
        let dupe_argv: Vec<ZBox> = args
            .iter()

View on GitHub (pinned to 8c5296ac45)