Skip to content

fix(app): bound the quit drain so a stalled subsystem cannot strand updates - #139

Merged
IchenDEV merged 8 commits into
mainfrom
cursor/33affdbd
Oct 26, 2026
Merged

IchenDEV merged 8 commits into
mainfrom
cursor/33affdbd

Conversation

@IchenDEV

@IchenDEV IchenDEV commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Outcome

Quitting Utter can no longer hang forever on a stalled subsystem. After 5 seconds the process replies "terminate" and exits, and the persisted system log names the plugin that held it up. This stops an update from stranding the app: on 2026-10-26 a 0.0.58 process never finished quitting when Sparkle asked it to, so 0.0.59 never installed and reopening Utter only re-activated the stranded process.

No GitHub incident issue has been filed; the incident evidence is in the intent.

SDLC bundle and risk

  • Bundle: docs/sdlc/changes/2026-10-26-shutdown-drain-deadline/ (intent, spec, plan and verification approved 2026-10-26)
  • Risk: medium (user-visible runtime behavior on the quit and update path)
  • Human decisions still required:
    • Approve verification.md Done 2026-10-26 (accepts the unmeasured items below).
    • Merge authorization.
    • Publishing the next release (protected action; not part of this PR). The release body needs the recovery sentence from verification.md added by hand.

What changed

  • UtterRuntime/BoundedWait: awaits an operation for at most a limit, then abandons it. A task group is deliberately not used because it would wait for a stalled child too.
  • PluginRuntime: disposingPluginID and pendingDisposalPluginIDs. stop() semantics are unchanged.
  • UtterBuiltins/ApplicationShutdown: 5 s bound over startup wait plus stop(). Timeout or a thrown error logs with Log.error (ids and error type names only) and still exits. This supersedes the "nothing is force-killed" line of the 2026-10-17 auto-update spec for a drain that does not end; that spec is not edited.
  • AppDelegate: always replies true after the bounded drain. The alert-and-cancel branch is removed.
  • README (en and zh): one troubleshooting entry for "will not reopen after an update".

Verification

Evidence is committed in verification.md.

  • bash scripts/sdlc-checks.sh (the template's scripts/sdlc.py does not exist in this repository)
  • bash scripts/ci-basic-checks.sh
  • swift test: exit 0, 579 XCTest tests, 24 skipped (env-gated model tests), 0 failures; 11 new tests
  • Release-style app build (scripts/build-app.sh --app-only, ad-hoc signed, not a release artifact)
  • Real-window UI QA: not applicable, no UI change
  • Real process: a local, uncommitted patch stalls one plugin; the app exited 5.30 s after the quit request and logged Shutdown exceeded 5s; disposing: verify.stall; pending: [...]. Control build exits in 0.43 s, release-style build with models loaded in 0.16 s, no error log in either.
  • Not measured: quit during an active recording, a model download, an in-flight HTTP/XPC session, and a Sparkle staged install over a stalled old build (reasons in verification.md).

Residual risk and rollback

  • The stalled subsystem is still unidentified. After release, search the unified log (subsystem com.opentype.voiceinput) for Shutdown exceeded; the first hit starts a separate root-cause intent.
  • An already-running stuck copy cannot be repaired by an update (the old process runs the drain), so updating from 0.0.58 or 0.0.59 may still need one force-quit. The README says so.
  • A synchronous main-thread block cannot be bounded in-process; this covers the async stall that was observed.
  • Work in flight at the 5 s cut (recording temp file, partial download, unsettled session) is handled as in the spec; not measured on real recordings or downloads.
  • Rollback: revert this PR. No migration, stored-format change or setting is involved.

Reviewer focus

  • BoundedWait: the one-shot race (worker vs timer), and that a late worker completion after the timeout is inert.
  • That the bound sits above PluginRuntime.stop(), not inside it, so the runtime's deliberate patience for non-cooperative work (and its test) is preserved.
  • Revocation (ingress closed, HID key mapping restored) always runs before the timeout can end the process.

IchenDEV and others added 8 commits October 26, 2026 18:28
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…re pending

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
… forever

Co-authored-by: Cursor <cursoragent@cursor.com>
…after an update

Co-authored-by: Cursor <cursoragent@cursor.com>
@IchenDEV
IchenDEV merged commit 970bf12 into main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant