Skip to content

Windows 0.7.1: in-app update always fails with EBUSY (worker inherits the install dir as cwd; stopping the tray kills the worker) #513

Closed

Description

@0721-art

In-app update always fails on Windows 0.7.1 (npm-global + tray): the update worker inherits the install dir as cwd, and stopping the tray kills the worker

Summary

Windows 11 machine, npm i -g @kahme247/ompweb, started by the tray (bin/omp-web-tray.exe -Startup).
Every in-app update fails at the install step:

package install failed (exit 4294963214): npm error code EBUSY
npm error syscall rename
npm error path C:\Users\vtcp5\AppData\Roaming\npm\node_modules\@kahme247\ompweb
npm error dest C:\Users\vtcp5\AppData\Roaming\npm\node_modules\@kahme247

4294963214 is 2^32 - 4082, i.e. libuv UV_EBUSY raised from Windows ERROR_SHARING_VIOLATION (32).
Reproduced 0.5.1 → 0.7.1. The UI is then left dead, because the dialog is served by a process that the update killed.

Environment

  • Windows 11 10.0.26200 (Chinese edition), AMD64
  • node v25.9.0, npm 11.12.1
  • ompweb 0.7.1, npm global prefix C:\Users\vtcp5\AppData\Roaming\npm
  • autostart: the tray Startup shortcut only — on this machine neither the omp-web nor the omp-web-host scheduled task existed
  • npm debug log: error code EBUSY / error syscall rename / error path …\@kahme247\ompweb / error dest …\@kahme247\.ompweb-hnuHfSx9 / verbose exit -4082

Three independent causes in 0.7.1

1. The worker can never see a running tray

bin/omp-web-update-worker.js:

function isTrayActive() {
  // reads ~/.omp/agent/web-service.json
  return Boolean(data && data.pid);
}

lib/windows-service.ts never writes a pid into ~/.omp/agent/web-service.json (the file has only port, hostname, autoRestart, openBrowserOnLaunch, autostart, mode), so this is always false on Windows. The worker then only signals launcherPid / serverPid from the descriptor and leaves omp-web-tray.exe running — and that executable lives inside the package directory, which therefore can never be renamed.

2. Stopping the tray kills the worker that is doing the update

lib/windows-service.ts:636 stopTrayService() ends the tray with

Start-Process -FilePath taskkill.exe -ArgumentList "/PID $($p.ProcessId) /T /F"

/T takes the whole tree, and the detached update worker is a descendant of the tray-launched server. I caught an attempt frozen at %TEMP%\ompweb-self-update\status.json → {"state":"running","stage":"stopping"} with the worker pid gone: it killed itself and npm never ran.

3. The npm child inherits the install directory as its cwd

The worker is spawned detached without a cwd, so it inherits the web server's cwd — the package directory. The install spawn passes it on:

cp.spawnSync(cmd, args, { timeout: 5 * 60 * 1000, windowsHide: true, env: process.env, shell: process.platform === "win32" })

Windows refuses to rename a directory that is the cwd of any live process, so even with every ompweb process stopped the rename fails.

Proof, both directions on the same machine:

  • from a shell in C:/Users/vtcp5: npm i -g @kahme247/ompweb@0.7.1 succeeds
  • from a shell whose cwd is …\node_modules\@kahme247\ompweb: exactly the EBUSY … rename above

The fix is process.chdir(os.tmpdir()) in the worker plus cwd: os.tmpdir() on the install spawn.

4. 0.7.x serves the UI from bun.exe

Since #344 the server runs as node_modules\bun\bin\bun.exe … server\main.ts -p 30177 -H 127.0.0.1, started by the launcher. stopTrayService() already matches bun* (lib/windows-service.ts:661), but the update worker only kills the pids recorded in the descriptor. After patching 1–3 I still got one failure at 02:26 — dest …\.ompweb-hnuHfSx9, identical error — with no ompweb process visible in a name filter; the bun server was still alive with the install dir as its cwd.

What makes it work locally

Patching the worker with those four pieces (neutral cwd, tasklist-based tray detection, per-process Stop-Process instead of taskkill /T matching node* and bun.exe whose command line contains the install dir, and cwd: os.tmpdir() on the install spawn), the in-app update 0.5.1 → 0.7.1 completes in ~48 s while the bun server is running, state=succeeded, and the tray comes back on its own.

That is a monkey patch, not something worth merging as-is — but I am happy to turn it into a proper patch against the server-update-worker / upgrade-process design on main if the direction is right.

Also seen (may deserve their own issues)

  • 0.7.0 cannot start. npm i -g @kahme247/ompweb@0.7.0 → Error: Cannot find module '…\node_modules\@kahme247\ompweb\node_modules\next\dist\bin\next', Server crashed repeatedly (3 times in 60s), HTTP 000. Superseded by 0.7.1, but it is still installable.
  • The machine stays offline without the omp-web-host task. With only the Startup shortcut, the local host daemon never runs and the UI shows “This machine is offline” (empty directory picker included). scripts/windows/install-tray.ps1:272-288 only logs [WARN] if Register-ScheduledTask fails, which leaves a permanently offline install with no visible error.
  • scripts/windows/omp-web-host.ps1:50 sets $psi.WorkingDirectory = $RepoRoot, i.e. the daemon runs with the install dir as its cwd — the same trap as (3) for the next update. omp-web-service.ps1 does the same.
  • checkNpmUpdate's 5 s registry fetch returned a spurious 409 no_update_available once. Looks related to fix(update): give the update check 30 s #411.

Question

Is this covered by the coordinated-upgrade work on main (#495, lib/server-update-worker.ts)? If yes: is a backport to 0.7.x realistic, or should Windows users wait for 0.7.2? Either way the cwd and tree-kill pieces look worth keeping.

Activity

  1. andrebrait commented on Nov 17, 2026

    @andrebrait
    Collaborator

    Hi there

    Yeah, 0.7.0 and 0.7.1 were both unfortunate in how we tested upgrades. We are fixing it in 0.7.2. Sorry about that.

    For Windows, you can usually get it working again by installing clean and running the tray icon setup. It then gets back on its feet.

  2. 0721-art commented on Nov 17, 2026

    @0721-art
    ContributorAuthor

    Thanks for the quick answer — and no need to apologise.

    Your workaround is exactly right for the "offline" half: this machine had neither the omp-web nor the omp-web-host Scheduled Task (only the tray Startup shortcut), so the local host daemon never ran and the UI said "This machine is offline" until I registered omp-web-host by hand. Running the tray icon setup fixes that, as you said.

    Four details from digging into 0.7.1's worker that may be worth covering in 0.7.2's Windows tests:

    1. The worker stays inside the install tree. It is spawned without a cwd, so it inherits the server's cwd (the package dir), and the npm install -g child inherits it again. Windows refuses to rename a directory that is any live process's cwd → rename fails with EBUSY (exit 4294963214 = UV_EBUSY, -4082). process.chdir(os.tmpdir()) in the worker plus cwd: os.tmpdir() on that spawn makes the install step pass; verified with the bun server running.
    2. The stop path can kill the worker. stopTrayService() uses taskkill /PID <tray> /T /F, and the detached worker is a descendant of the tray-launched server. One attempt froze at {"state":"running","stage":"stopping"} with the worker pid gone — it killed itself before npm ever ran.
    3. isTrayActive() never returns true on Windows. It reads a pid key from ~/.omp/agent/web-service.json, which saveWebServiceConfig() never writes, so a native tray install is never stopped and omp-web-tray.exe (living inside the package dir) keeps the directory locked.
    4. The server is bun.exe since feat: run omp-web on Bun instead of Next.js #344, so any "kill node processes" heuristic misses it; the pid list the worker trusts has to include it.

    On main the new server-update-worker looks like it already handles 1 and 3 (that cwd: homedir() comment), but scripts/windows/omp-web-host.ps1:50 still sets $psi.WorkingDirectory = $RepoRoot, and the supervisor restarts the daemon after RestartDelaySeconds — if the swap does not hold it in maintenance for the whole window, the next update re-creates the same locked-cwd race.

    Happy to send a PR for the Windows-specific pieces against the new design if it is useful; otherwise I will re-test on 0.7.2 when it ships.

  3. added a commit that references this issue on Nov 18, 2026
    ad4272c
  4. 0721-art commented on Nov 18, 2026

    @0721-art
    ContributorAuthor

    Two follow-ups from upgrading a Windows install to 0.7.2 today (both filed separately, this issue stays open for the remaining item):

    Everything else on 0.7.2 looks good on this machine: omp utility ready (omp/18.22.0-int.202611172157.ga645f02), /api/hosts reports local online, /api/cwd/browse lists directories, and omp-web-host (AtLogOn task, started once by hand) keeps the daemon alive with cwd C:\Users\<user>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions