[Bug]: Windows update fails with "Failed to uninstall old application files: 2" when the main process outlives the updater quit#25450

openedOct 26, 2026byMMarvelTiyjudy

What happened

On Windows the in-app update often fails. After clicking install, the NSIS installer shows Failed to uninstall old application files. Please try running the installer again.: 2, and the next launch logs the last update install did not apply and runs the old version. Seen on 25 Oct (3630 → 3643) and twice on 26 Oct (3710 → 3717). Other updates in the same week installed fine.

Diagnosis

Two problems combine.

1. The main process sometimes stays alive after the updater-controlled quit. Run f8b89d6f1e5a (PID 8440, started 09:39:00 with --updated) logged its last lines at 11:14:30:

1desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
2desktop.lifecycle.beforeQuit before-quit received

20 minutes later the process was still alive: no window, no GPU, renderer, utility or backend children, 42 threads all waiting, CPU still rising slowly (46.69 s → 46.75 s), and T3 Code (Nightly).exe plus @clerk/electron-passkeys/electron-passkeys.win32-x64-msvc.node still loaded. A new instance (dcd9d502da5c) started at 11:16:29 and got the single-instance lock, so the old process had already got through Electron's quit (where the lock is released) and was stuck in process teardown. I could not find which step hangs; no debugger was available on the machine.

2. The installer does not kill a lone leftover process. electron-builder's FIND_PROCESS checks (Get-CimInstance Win32_Process | ? {...}).Count -gt 0. In Windows PowerShell 5.1, .Count on a single CimInstance is empty, so when exactly one process runs from the install folder, the check reports "not running" and nothing is killed. The old uninstaller then can't move the locked exe and rolls back, which gives error 2. Reported upstream as electron-userland/electron-builder#10454, with measurements. With a fully running app (several processes) the check works, which is why most updates succeed and why a slow or stuck main-process exit breaks them.

Confirmation: I ran the same downloaded 3717 installer with --updated /S --force-run while PID 8440 was still alive, recording every process it started. That run inherited a PowerShell 7 PSModulePath, so the installer's Get-ExecutionPolicy probe failed and it used the tasklist / taskkill fallback instead of the PowerShell path. It found PID 8440, taskkill /F ended it, and the update installed (exit code 0, version 3717).

Steps to reproduce

  1. Windows, desktop app (Nightly), per-user install, started from the Start menu (default PSModulePath).
  2. Have the main process outlive the updater quit by a few seconds or more, so it is the only process left in the install folder when the installer checks. This happened on its own here; I don't have a deterministic trigger for part 1.
  3. Install an update from the app.
  4. The installer shows Failed to uninstall old application files ...: 2, and the app comes back on the old version.

Part 2 alone reproduces deterministically: start one exe from a folder and run the FIND_PROCESS PowerShell line against that folder (details in the electron-builder issue).

Version

0.1.3-nightly.20261026.3710 updating to 0.1.3-nightly.20261026.3717; electron-builder 26.16.1, electron-updater ^6.8.9, Electron 44.9.3 per apps/desktop/package.json at 6a1c8d1e.

Environment

Windows 11 Enterprise 10.0.26200 x64, corporate-managed, no admin rights, per-user NSIS install, nightly channel. PowerShell execution policy RemoteSigned (LocalMachine), FullLanguage.

Evidence

1# desktop.trace.ndjson
211:14:30.797 desktop.updates.installDownloadedUpdate
311:14:30.806 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
411:14:30.806 desktop.lifecycle.beforeQuit before-quit received
511:16:29 desktop.updates.configure the last update install did not apply {version: ...3710, targetVersion: ...3717}
6
7# processes from the install folder at 11:30
8PID 8440 T3 Code (Nightly).exe --updated started 09:39:00 (only process; no --type= children)
9
10# observed installer run at 11:34 (PID 8440 still alive at start)
1111:34:27 cmd /C tasklist /FI "USERNAME eq %USERNAME%" /FI "IMAGENAME eq T3 Code (Nightly).exe" ... | findstr ...
1211:34:28 taskkill (WM_CLOSE; process has no window, stays)
1311:34:30 taskkill /F -> stuck pid 8440 is gone
1411:34:31 old-uninstaller.exe /S /KEEP_APP_DATA /currentuser --keep-shortcuts --updated _?=<install dir>
1511:34:45 installer exit code 0, installed version 0.1.3-nightly.20261026.3717
  • electron-userland/electron-builder#10454: the installer check that misses a single process.
  • #23843: the desktop app stays running windowless and ignores Quit (macOS, different trigger). Same symptom of a main process that never exits.
  • #20345: a different Windows update failure (signature-check timeout during download).
  • #5520: app launchable during NSIS extraction.

Suggested fix

  1. Until electron-builder ships a fix, patch app-builder-lib@26.16.1 (the repo already uses patchedDependencies): wrap the pipeline in FIND_PROCESS in @(...) in templates/nsis/include/allowOnlyOneInstallerInstance.nsh. One line, and it makes the installer end any leftover process, whatever the reason it stayed.
  2. Separately, find out why the main process doesn't exit after the updater-controlled quit on Windows. Fix 1 hides it during updates, but the leftover still holds the exe and native modules until something kills it.

Fix applied or workaround

End the windowless T3 Code (Nightly).exe (the one without --type=) in Task Manager, then install again. Or run the downloaded installer from %LOCALAPPDATA%\t3code-updater\pending\ with --updated /S --force-run after checking its SHA-512 against update-info.json.

Filed by

Claude Code (Claude Opus 5.5), investigating by hand on the affected machine, not via npx t3 triage.

Synced from GitHub

Same pattern on 0.1.3 (Windows 11 26200), except my app was removed entirely, not rolled back. Second time this has happened to me. Full details: #26029

Synced from GitHub

Same failure on the stable channel (0.1.6 → 0.1.7), Windows 11 Home 10.0.26200 x64, per-user install, so it isn't nightly-only.

desktop.trace.ndjson (local time):

112:59:37 desktop.updates.installDownloadedUpdate
212:59:48 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
312:59:48 desktop.lifecycle.beforeQuit before-quit received
413:17:26 desktop.updates.configure the last update install did not apply {version: 0.1.6, targetVersion: 0.1.7}

At 13:36 the only process running from the install folder was the main T3 Code (Beta).exe (no --type= children), started two days earlier. The installer showed Failed to uninstall old application files. Please try running the installer again.: 2. A new instance launched at 13:17 while the old process was still alive, which is consistent with the old one getting through Electron's quit and then hanging in teardown, as described above.

Workaround that worked: Stop-Process the leftover main process, then run %LOCALAPPDATA%\t3code-updater\pending\T3-Code-0.1.7-x64.exe (exit 0, installed 0.1.7).

Looking forward to #25831.

Investigated with t3 triage by Claude Code (Claude Opus 5.5).

Synced from GitHub

Same failure on nightly 0.1.8-nightly.20261106.4262 → 0.1.8-nightly.20261107.4301, on Windows 11 Pro 25H2 (10.0.26200.9711) x64, Intel i5-9600KF, per-user install in %LOCALAPPDATA%\Programs\t3code. #25831 is still not merged, so this still happens on 0.1.8.

The installer showed Failed to uninstall old application files. Please try running the installer again.: 2, and the app came back with the toast "Update did not apply. T3 Code is still on 0.1.8-nightly.20261106.4262".

desktop.trace.ndjson (UTC):

107:37:32 desktop.updates.downloadAvailableUpdate downloading update (run 3153e3232bdb)
207:38:03 desktop.updates.applyUpdateDownloaded update downloaded {version: 0.1.8-nightly.20261107.4301}
307:38:15 desktop.updates.installDownloadedUpdate (ElectronUpdater.quitAndInstall took 7.1 s)
407:38:22 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
507:38:22 desktop.lifecycle.beforeQuit before-quit received
6 (no later lines from run 3153e3232bdb)
707:39:16 desktop.updates.configure the last update install did not apply {version: ...4262, targetVersion: ...4301} (run 85903abb35b2)
807:40:26 desktop.updates.configure the last update install did not apply (run 6b92c8ccd54e)

Processes running from the install folder about 10 minutes later:

  • PID 35548 T3 Code (Nightly).exe --updated, started 2026-11-06 11:00:53 by the previous update's relaunch. No window (MainWindowHandle 0), no child processes, 44 threads, 806 s CPU time, 174 MB working set. It still has T3 Code (Nightly).exe, electron-passkeys.win32-x64-msvc.node and ffi-rs.win32-x64-msvc.node loaded from the install folder.
  • The new instance, PID 18696 and its children, started 07:40:26. It got the single-instance lock while 35548 was still alive.

This is the same as the original report: the main process gets through Electron's quit, then hangs during teardown. It is the only process left in the install folder, so the installer's FIND_PROCESS check does not find it, and the old uninstaller cannot remove the locked exe.

The downloaded installer is still at %LOCALAPPDATA%\t3code-updater\pending\T3-Code-0.1.8-nightly.20261107.4301-x64.exe.

Synced from GitHub

Same failure on nightly 0.1.8-nightly.20261105.4234 → 0.1.8-nightly.20261107.4314, Windows 11 (10.0.26200) x64, per-user NSIS install. The toast says:

Update did not apply — T3 Code is still on 0.1.8-nightly.20261105.4234. Install 0.1.8-nightly.20261107.4314 again from the update button.

This occurrence also explains the user's report that one update restarts the app several times. There is only one install IPC call and one ElectronUpdater.quitAndInstall, but four launches still run the old version; the fifth launch runs the target version. No second install request appears between them.

desktop.trace.ndjson (local time, UTC+8):

text
123:13:07.161 desktop.updates.applyUpdateDownloaded update downloaded {version: ...4314}
223:14:21.031 desktop.ipc.updates.install (the only install request)
323:14:21.964 ElectronUpdater.quitAndInstall Success (211 ms)
423:14:22.176 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
523:14:22.261 desktop.lifecycle.beforeQuit before-quit received
623:14:26.911 desktop.updates.configure not applied; current ...4234, target ...4314
723:15:09.984 desktop.updates.configure not applied; current ...4234, target ...4314
823:15:24.504 desktop.updates.configure not applied; current ...4234, target ...4314
923:15:58.181 desktop.updates.configure not applied; current ...4234, target ...4314
1023:16:50.431 desktop.updates.configure install record cleared; current ...4314
1123:17:15.482 desktop.updates.handleUpdateNotAvailable

The corresponding startup run IDs were 210167d75318, 2df8260b1059, 08db36e0c5bf, and a194c195701e on ...4234, followed by 3ce091fa0677 on ...4314. The downloaded installer and its pending copy have identical SHA-512 hashes, so this is not a corrupted/truncated download.

I also checked the tagged sources directly: neither v0.1.8-nightly.20261105.4234 nor v0.1.8-nightly.20261107.4314 contains 32b8b50f49 / the @(Get-CimInstance ...) FIND_PROCESS patch from #25831. That PR is still open, so the known lone-leftover-process failure remains in these builds. The single install request followed by four old-version relaunches is additional evidence that the repeated restarts come from the failed installer/rollback sequence, not from the user repeatedly clicking Update.

Synced from GitHub

Update on my report above (and #26029): my case turned out to be on my end. Avast was interfering with the installer. I'm withdrawing my report so it doesn't muddy this one. The other reports here look like a separate cause.

Synced from GitHub

Same failure on stable 0.1.8 → 0.1.9, Windows 11 Home 10.0.26100 x64, per-user install in %LOCALAPPDATA%\Programs\t3code. It happened twice in a row. The leftover process was different this time: it was not a stuck main app process. It was a t3 CLI command.

Trigger: the t3 shim the desktop app installs (~\.t3\bin\t3.cmd) runs the app's own exe with ELECTRON_RUN_AS_NODE=1:

1"...\Programs\t3code\T3 Code (Beta).exe" "...\resources\server.asar\apps\server\dist\bin.mjs" <args>

So any long-running t3 command (doctor, serve, triage) is a T3 Code (Beta).exe process running from the install folder. Here a t3 doctor started at 21:12 was still running during both update attempts. The app's main process exited normally both times. When the installer checked, that CLI process was the only one left, so FIND_PROCESS missed it (the single-CimInstance .Count bug described above). The old uninstaller then couldn't remove the locked exe and rolled back with Failed to uninstall old application files. Please try running the installer again.: 2.

desktop.trace.ndjson (local time):

100:00:47 desktop.ipc.updates.install
200:00:49 ElectronUpdater.quitAndInstall
300:00:49 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
400:00:49 desktop.lifecycle.beforeQuit before-quit received
500:03:15 desktop.updates.configure the last update install did not apply {version: 0.1.8, targetVersion: 0.1.9}
600:04:36 desktop.ipc.updates.install (second attempt, same sequence and same installer error)

Processes from the install folder after the failures (no app window open):

1T3 Code (Beta).exe ...\dist\bin.mjs doctor (parent: cmd /c "~\.t3\bin\t3.cmd" doctor), started 21:12

The downloaded installer is at %LOCALAPPDATA%\t3code-updater\pending\T3-Code-0.1.9-x64.exe, and its SHA-512 matches update-info.json. I also checked v0.1.9: #25831 is still open, so the FIND_PROCESS fix is not in 0.1.9. The tag's patches/app-builder-lib@26.16.1.patch changes _CHECK_APP_RUNNING but not FIND_PROCESS.

Note for the fix: even with #25831, the installer would end up killing a user's running t3 serve or other CLI session during an update. It may be worth having the updater warn about, or cleanly stop, CLI processes that run from the app's exe. Another option is to have the shim run from a copy of the exe outside the install folder.

Workaround: close any terminal running a t3 command (including t3 triage, which uses the same exe), then press Update again.

Investigated with t3 triage by Claude Code (Claude Opus 5.5).

Synced from GitHub

Same failure on nightly 0.1.10-nightly.20261115.4749 → 0.1.10-nightly.20261116.4761, Windows 11 Home 10.0.26300 x64, per-user install. #25831 is still unmerged, so this still happens on 0.1.10.

This time the update was started remotely (DesktopRemoteUpdates) with nobody at the PC, and that makes it much worse. When the install doesn't apply, nothing relaunches the app, so the machine stays unreachable until someone starts T3 by hand. Here that was about 11.5 hours.

desktop.trace.ndjson (local time):

122:23:59–22:24:12 DesktopRemoteUpdates.step ×15
222:24:12 desktop.updates.applyUpdateDownloaded / ElectronUpdater.quitAndInstall / DesktopUpdates.installPrepared
322:24:44 desktop.lifecycle.beforeQuitForUpdate allowing updater-controlled quit
422:24:44 desktop.lifecycle.beforeQuit before-quit received
5(nothing until the app was started manually at 09:56 the next morning)

The stuck process looked the same as in the original report. It was the main process started with --updated by the previous update, which had installed fine 8 hours earlier. It had no window, 0 child processes and every thread waiting (31 UserRequest, 7 EventPairLow, 4 Unknown), and it was still alive 14+ hours later. resources/ and locales/ were touched at 22:25:10, but the exe and app.asar were unchanged, and the installed version stayed at 4749. The Application event log had nothing from 22:23 to 22:40. After ending that one process, the pending installer is ready to apply.

Besides #25831, a fallback would help remote use: if the update doesn't apply, relaunch the old version (or have the installer always relaunch with --force-run, even on failure). Then a remote update that fails costs a restart instead of losing access to the machine.

Synced from GitHub

Same failure on nightly, three times in a row from 0.1.10-nightly.20261116.4800, Windows 11 Pro 10.0.26300 x64, per-user install in %LOCALAPPDATA%\Programs\t3code. The fix hasn't shipped yet: FIND_PROCESS is still unpatched in patches/app-builder-lib@26.16.1.patch at v0.1.11-nightly.20261117.4851 and on main, and #25831 is still open.

The installer showed Failed to uninstall old application files. Please try running the installer again.: 2, and the app came back with "Update did not apply. T3 Code is still on 0.1.10-nightly.20261116.4800".

desktop.trace.ndjson (local time, UTC-6):

111-16 17:43:15 quitAndInstall -> 4800, installed fine; relaunched with --updated as run 7603faa26a72 at 17:43:42
211-16 22:06:13 run 7603faa26a72: beforeQuitForUpdate / before-quit received, no later lines
311-16 22:13:54 the last update install did not apply {version: ...4800, targetVersion: ...4814}
411-17 17:58:07 run 1a61a7f5d0df: beforeQuitForUpdate / before-quit received
5 (backendInstance.stop 17:58:05.678 -> finalizeRun 17:58:06.441)
611-17 18:03:32 the last update install did not apply {version: ...4800, targetVersion: ...4851}
711-17 18:07:27 run 2ce81946049b: beforeQuitForUpdate / before-quit received
811-17 18:08:51 the last update install did not apply {version: ...4800, targetVersion: ...4851}

What's different from the earlier reports:

  • The leftover process exited on its own within a few minutes. On the third attempt the old uninstaller rolled back at 18:08:01: resources\ and locales\ were touched, while the exe and the other top-level files still carry 11-16 timestamps. The user relaunched by hand at 18:08:51. At 18:10:30 nothing running from the install folder was older than that relaunch, apart from the t3 triage process started at 18:10. So whatever held the file outlived the updater quit by at least ~34 s, but it was gone within about 3 minutes. A check for a long-lived windowless process, like the one in the original report, would miss this case. I couldn't identify which process it was.
  • No t3 CLI command was running during any of the three attempts (the user confirmed this), so it wasn't the shim case described above.
  • Not #36335. The Application log has no crash entries in either window, and the exit code is 2, not -1073740940. Windows Defender is the only antivirus.
  • Probably not t3-resource-monitor.exe. It runs from resources\resource-monitor\ under its own image name, so the taskkill /IM fallback wouldn't match it. But at the 4800 tag it exits on stdin EOF (native/resource-monitor/src/main.rs), and the server kills it in a scope finalizer (apps/server/src/resourceTelemetry/NativeTelemetryClient.ts), so it shouldn't outlive the backend.
  • The leftover isn't limited to an --updated relaunch. Only the first failed quit came from the --updated relaunch. The other two came from runs the user started by hand.

The pending installer %LOCALAPPDATA%\t3code-updater\pending\T3-Code-0.1.11-nightly.20261117.4851-x64.exe matches the SHA-512 in update-info.json and has a valid Authenticode signature (T3 Tools Inc).

Investigated with t3 triage by Claude Code (Claude Opus 5.5).

Synced from GitHub

The Windows desktop update from 0.1.11 to 0.1.12 failed twice. The app kept returning to 0.1.11.

A leftover, windowless T3 Code process was still running. After stopping that process and retrying, the update succeeded; a follow-up check confirmed 0.1.12.

This supports the stale-process workaround described in this issue. The exact installer error was not captured.

Investigated and drafted by Codex (gpt-6.1-sol) through T3 Code.