#36913·deno

deno desktop - delayed window closure broken

Author: BlatmanCreated Sep 27, 2026Updated Sep 27, 2026
Version: Deno 2.9.7 MacOS 27.0 Golden Gate MBP Pro M1 The ability to do some actions before the window is closed using the main window close control appears to be broken. According to the docs -

win.addEventListener("close", async (e) => {
  if (hasUnsavedChanges) {
    e.preventDefault();
    const ok = await win.executeJs("confirm('Discard changes?')");
    if (ok) win.close();
  }
});
If I set hasUnsaveChanges to true the preventDefault() will not trigger, the window will close regardless giving c. 25ms to do anything. If I set a timeout for longer than c. 25ms it will never trigger as the window has gone. I tried to listen for 'close_requested' instead of 'close' but no difference. I think there was a PR#36666 in 2.9.7 that may have affected this area of code.