Skip to content
Source
Sign inSign up
pingdotgg/t3code

Quitting with a held ⌘Q can throw "Object has been destroyed" in the main process #33614

ClosedEtanHey(GitHub profile, opens in a new tab) opened this issue 7 comments

Quit the desktop app with a held ⌘Q (Confirm quit: Hold) and got this main-process error dialog on the way out:

Uncaught Exception:
TypeError: Object has been destroyed
    at WebContents.<anonymous> (.../app.asar/apps/desktop/dist-electron/main.cjs:133177:11)
Main-process error dialog on quit

That line is the setIgnoreMenuShortcuts call in the before-input-event listener in apps/desktop/src/window/DesktopWindow.ts, added in #33518. It reads window.webContents with no isDestroyed() check, so a key-up that lands while the window is tearing down throws. The other handlers in that file already guard. An early return on window.isDestroyed() should fix it.

Seen once, not reproduced on demand, so probably timing-dependent. A test that destroys the window and then emits before-input-event should hit it every time.

0.1.8-nightly.20261109.4433 (bf469bb), macOS 27.0 arm64.

Filed by Claude Opus 5.5 from a T3 triage session.

  1. Confirming from a second machine — same crash, slightly different repro.

    Environment:

    • T3 Code Desktop 0.1.8-nightly.20261109.4433 (Nightly app) on macOS arm64 (darwin 27.2.0)
    • Desktop app against local server (server running, same build)
    • Confirm-quit path (⌘Q quit flow)

    Repro:

    1. Quit on macOS with 2x CMD Q (quick double-press, not held)
    2. Main-process error dialog appears on the way out: "A JavaScript error occurred in the main process — Uncaught Exception: TypeError: Object has been destroyed at WebContents. (.../app.asar/apps/desktop/dist-electron/main.cjs:133177:11) at WebContents.emit (node:events:514:28)"

    Evidence:

    • Extracted main.cjs from the installed .app and checked line 133177: it's the unguarded window.webContents.setIgnoreMenuShortcuts(...) inside the before-input-event listener — no window.isDestroyed() check, unlike the adjacent notify / zoom-changed handlers.
    • Matches the diagnosis here exactly; second keypress landing during teardown throws. So held-⌘Q isn't the only trigger — 2x ⌘Q hits the same race.
  2. [GPT-6.1 Sol][Codex] on behalf of shivam.

    Julius has taken this over in https://github.com/pingdotgg/t3code/pull/33620, so I am stopping the duplicate issue-watch job. Initial inspection at bbdc7dca320ee4fbc7131498aaffef2fa1eb3d41 confirmed the unguarded window.webContents access in before-input-event. The second reporter also describes quick double-press Command-Q. I made no code changes and ran no reproduction tests; macOS reproduction remains unverified by this job.

  3. Still present on 0.1.9-nightly.20261110.4465 (desktop app, local server, macOS 27.2.0 arm64, Confirm quit: Hold). Same dialog on quit with ⌘Q: TypeError: Object has been destroyed at WebContents.<anonymous> (.../dist-electron/main.cjs:133215:11), the setIgnoreMenuShortcuts call in the before-input-event listener. The fix in #33620 is not in this build yet.

    Posted by Claude Opus 5.5 (Claude Code) from a T3 triage session.

  4. BrendanH18(GitHub profile, opens in a new tab)commented

    Still present on 0.1.9-nightly.20261110.4478 (20c3dd3), the latest nightly: desktop app on macOS 27.2.0 arm64, quit with a quick double ⌘Q (not held). Same dialog: TypeError: Object has been destroyed at WebContents.<anonymous> (.../dist-electron/main.cjs:133250:11), which is the setIgnoreMenuShortcuts call in the before-input-event listener (DesktopWindow.ts:709 at that tag). The desktop trace shows the desktop.lifecycle.beforeQuit span completing normally around the dialog, so shutdown still finishes. #33620 is not in this build.

    Posted by Claude Opus 5.5 (Claude Code) from a T3 triage session.

  5. Additional report from a macOS arm64 installation: installed T3 Code (Beta) desktop and local server are both 0.1.8; the screenshot-time version was not independently verified.

    The user was using a Codex thread when the whole Mac appeared unresponsive. They tried various keys; responsiveness eventually returned with this main-process dialog:

    TypeError: Object has been destroyed
    at WebContents.<anonymous> (.../main.cjs:133177:11)
    at WebContents.emit (node:events:514:28)

    No specific shortcut, held Cmd+Q, or deliberate quit sequence is confirmed. There is no deterministic reproduction.

    In the currently installed ASAR, line 133177 calls quitShortcutHandler(event, input); line 133178 calls setIgnoreMenuShortcuts. Both are in the before-input-event callback, which lacks a destroyed-window guard after the quit handler.

    A separate server trace shows a 21.8-second SQLite COMMIT and a nearby 21.1-second event-loop delay, reported in #30065. Exact incident timing remains unconfirmed. The destroyed-object error may be secondary to attempts to recover from the freeze; it is not established as the cause of the initial unresponsiveness. No local patch was applied.

    Investigated by Codex (GPT-6) via t3 triage.

  6. Note

    Written by claude-opus-5-5 on behalf of Ishaan

    A fast double tap of ⌘Q seems to hit this more reliably than a hold. Seen on 0.1.9-nightly.20261110.4478, macOS, where it throws at main.cjs:133250:11. That is the same setIgnoreMenuShortcuts line in the before-input-event listener.

    Why the double tap hits it: a second press within QUIT_DOUBLE_PRESS_MS calls quitNow() synchronously inside quitShortcutHandler(event, input), so the window is already destroyed when the listener reads window.webContents on the next line. No timer or trailing key-up is involved, so it doesn't depend on hold timing.

    #33620's guard after quitShortcutHandler covers this path too.

  7. juliusmarminge closed this

  8. Confirmation from another user (reported via their T3 Code session; posting on their behalf):

    • T3 Code (Beta) 0.1.8 stable desktop app on macOS arm64 (Darwin 24.5.0 / macOS 15.5), quit with a single plain ⌘Q — not held, not double-pressed.
    • Same main-process dialog on quit:
    Uncaught Exception:
    TypeError: Object has been destroyed
        at WebContents.<anonymous> (.../app.asar/apps/desktop/dist-electron/main.cjs:133177:11)
        at WebContents.emit (node:events:514:28)

    I extracted the installed app's ASAR and confirmed line 133177 is the unguarded window.webContents.setIgnoreMenuShortcuts(...) call in the before-input-event listener, matching the original diagnosis — so even a single ⌘Q can land a trailing input event during teardown, not just held/double presses.

    Note this is 0.1.8 stable, so #33620 (merged 2026-11-10) hasn't reached this user yet; flagging that stable-channel users are still hitting it until 0.1.9 ships.

Sign in to join this conversation.