denoland/deno · error
failed to unregister: {}
Error message
failed to unregister: {} What it means
On Windows, each spawned child registers a wait object; the Waiting struct unregisters it in Drop via UnregisterWaitEx and panics if the call fails. Drop has no error channel, so a failed unregister aborts instead of leaking the registration silently.
Source
Thrown at runtime/subprocess_windows/src/process.rs:251
GlobalJobHandle(job)
}
});
}
#[derive(Debug)]
struct Waiting {
rx: oneshot::Receiver<()>,
wait_object: HANDLE,
tx: *mut Option<oneshot::Sender<()>>,
}
impl Drop for Waiting {
fn drop(&mut self) {
unsafe {
let rc = UnregisterWaitEx(self.wait_object, INVALID_HANDLE_VALUE);
if rc == 0 {
panic!("failed to unregister: {}", io::Error::last_os_error());
}
drop(Box::from_raw(self.tx));
}
}
}
unsafe impl Sync for Waiting {}
unsafe impl Send for Waiting {}
pub struct SpawnOptions<'a> {
// pub exit_cb: Option<fn(*const uv_process, u64, i32)>,
pub flags: u32,
pub file: Cow<'a, OsStr>,
pub args: Vec<Cow<'a, OsStr>>,
pub env: &'a CommandEnv,
pub cwd: Option<Cow<'a, OsStr>>,
pub stdio: Vec<super::process_stdio::StdioContainer>,
}View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Drop child/process objects in a clean order before tearing down the runtime
- Let the API own internal handles; never clone or duplicate them manually
- If embedding, shut down subprocess tracking before dropping the isolate
- Report upstream if reproducible - Drop-order failures here are treated as bugs
Defensive patterns
Strategy: validation
Prevention
- Join/drop all child-process handles before dropping the runtime or isolate
- Never duplicate or manually free internal wait handles owned by the subprocess API
- Ensure shutdown code runs in a single ordered path (no racing teardown from multiple threads)
When it happens
Trigger: Dropping the Waiting registration when its wait handle is already invalid: dropping during process or thread teardown after handles were closed, dropping the registration twice, or runtime shutdown racing the wait thread.
Common situations: Embedders tearing down the runtime while subprocess state is alive; abnormal shutdown paths on Windows; code that duplicates internal handles.
Related errors
- {}: ({}) {}
- Initialize libloading failed {}
- nul byte found in provided data
- Process not found
- Invalid arguments
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/0b81e4e888f10944.
Report an issue: GitHub.