{"record":{"id":"0b81e4e888f10944","repo":"denoland/deno","slug":"failed-to-unregister","errorCode":null,"errorMessage":"failed to unregister: {}","messagePattern":"failed to unregister: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runtime/subprocess_windows/src/process.rs","lineNumber":251,"sourceCode":"\n      GlobalJobHandle(job)\n    }\n  });\n}\n\n#[derive(Debug)]\nstruct Waiting {\n  rx: oneshot::Receiver<()>,\n  wait_object: HANDLE,\n  tx: *mut Option<oneshot::Sender<()>>,\n}\n\nimpl Drop for Waiting {\n  fn drop(&mut self) {\n    unsafe {\n      let rc = UnregisterWaitEx(self.wait_object, INVALID_HANDLE_VALUE);\n      if rc == 0 {\n        panic!(\"failed to unregister: {}\", io::Error::last_os_error());\n      }\n      drop(Box::from_raw(self.tx));\n    }\n  }\n}\n\nunsafe impl Sync for Waiting {}\nunsafe impl Send for Waiting {}\n\npub struct SpawnOptions<'a> {\n  // pub exit_cb: Option<fn(*const uv_process, u64, i32)>,\n  pub flags: u32,\n  pub file: Cow<'a, OsStr>,\n  pub args: Vec<Cow<'a, OsStr>>,\n  pub env: &'a CommandEnv,\n  pub cwd: Option<Cow<'a, OsStr>>,\n  pub stdio: Vec<super::process_stdio::StdioContainer>,\n}","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/runtime/subprocess_windows/src/process.rs#L233-L269","documentation":"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.","triggerScenarios":"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.","commonSituations":"Embedders tearing down the runtime while subprocess state is alive; abnormal shutdown paths on Windows; code that duplicates internal handles.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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)"],"tags":["windows","subprocess","cleanup","drop","handle","panic"],"backgroundTag":"resource-cleanup-failure","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}