Repository navigation
Description
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-webnor theomp-web-hostscheduled 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.1succeeds - from a shell whose cwd is
…\node_modules\@kahme247\ompweb: exactly theEBUSY … renameabove
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-hosttask. 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-288only logs[WARN]ifRegister-ScheduledTaskfails, which leaves a permanently offline install with no visible error. scripts/windows/omp-web-host.ps1:50sets$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.ps1does the same.checkNpmUpdate's 5 s registry fetch returned a spurious409 no_update_availableonce. 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
andrebrait commentedon Nov 17, 2026
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.
0721-art commentedon Nov 17, 2026
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-webnor theomp-web-hostScheduled Task (only the tray Startup shortcut), so the local host daemon never ran and the UI said "This machine is offline" until I registeredomp-web-hostby 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:
cwd, so it inherits the server's cwd (the package dir), and thenpm install -gchild inherits it again. Windows refuses to rename a directory that is any live process's cwd →renamefails withEBUSY(exit4294963214=UV_EBUSY,-4082).process.chdir(os.tmpdir())in the worker pluscwd: os.tmpdir()on that spawn makes the install step pass; verified with the bun server running.stopTrayService()usestaskkill /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.isTrayActive()never returns true on Windows. It reads apidkey from~/.omp/agent/web-service.json, whichsaveWebServiceConfig()never writes, so a native tray install is never stopped andomp-web-tray.exe(living inside the package dir) keeps the directory locked.bun.exesince 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
mainthe newserver-update-workerlooks like it already handles 1 and 3 (thatcwd: homedir()comment), butscripts/windows/omp-web-host.ps1:50still sets$psi.WorkingDirectory = $RepoRoot, and the supervisor restarts the daemon afterRestartDelaySeconds— 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.
fix(windows): start launchers outside the installation directory
fix(windows): let in-app updates replace an npm-global install (ompwe…
0721-art commentedon Nov 18, 2026
Two follow-ups from upgrading a Windows install to 0.7.2 today (both filed separately, this issue stays open for the remaining item):
bin/omp-web-tray.exein 0.7.2 is a prebuilt binary from3a56e79(2026-11-14), 30 commits behindmainat the tag.native/tray/Program.csonv0.7.2hasWorkingDirectory = workingDirectory(the fix(windows): start launchers outside the installation directory #515 fix) but the shipped binary still behaves likeWorkingDirectory = _repoRoot: with the tray started fromC:\Users\<user>, its childnode ...\ompweb\bin\omp-web.jsstill runs with the installation directory as cwd. So the cwd lock from this issue is not fixed by 0.7.2 on Windows, and any futureswapInstallDirectory()rename is still exposed.~/.omp/agent/omp-web/omp/0.7.2/<tag>/ompweb-omp.exewith the sha256 fromompweb-omp.sha256letprepare/commitfinish in ~2 minutes.Everything else on 0.7.2 looks good on this machine:
omp utility ready (omp/18.22.0-int.202611172157.ga645f02),/api/hostsreportslocalonline,/api/cwd/browselists directories, andomp-web-host(AtLogOn task, started once by hand) keeps the daemon alive with cwdC:\Users\<user>.