Skip to content

fix: kill orphaned node.exe before NSIS install to prevent file lock error#948

Merged
web3dev1337 merged 2 commits into
mainfrom
fix/nsis-kill-node-before-install
Mar 20, 2026
Merged

fix: kill orphaned node.exe before NSIS install to prevent file lock error#948
web3dev1337 merged 2 commits into
mainfrom
fix/nsis-kill-node-before-install

Conversation

@web3dev1337
Copy link
Copy Markdown
Owner

@web3dev1337 web3dev1337 commented Mar 20, 2026

Summary

  • Fixes the Windows installer error: "Error opening file for writing: C:\Users[User]\AppData\Local\agent-workspace\resources\backend\node\node.exe"
  • Root cause: the bundled node.exe (spawned as the backend server) remains running as an orphaned process after app close or uninstall, holding a file lock on itself — the NSIS installer cannot overwrite it
  • Adds a custom NSIS preinstall hook (src-tauri/windows/hooks.nsh) that taskkill /F both Agent Workspace.exe and node.exe before file extraction begins
  • Same cleanup added to the preuninstall hook for clean removal

Files changed

  • src-tauri/windows/hooks.nsh — new NSIS hook file with NSIS_HOOK_PREINSTALL and NSIS_HOOK_PREUNINSTALL macros
  • src-tauri/tauri.conf.json — added bundle.windows.nsis.installerHooks pointing to the hook file

Test plan

  • Build NSIS installer (npm run tauri:build or npm run tauri:build:fast)
  • Install the app, start it (so node.exe is running)
  • Close the app but leave node.exe orphaned (or don't close — either way)
  • Run the installer again — should succeed without "Error opening file for writing"
  • Verify the app launches correctly after reinstall

Note

The taskkill /IM node.exe /F is broad and will kill all node.exe processes on the machine. This is acceptable because:

  1. It only runs during install/uninstall (not at runtime)
  2. Users expect installers to briefly interrupt other processes
  3. The alternative (users manually killing node via Task Manager) is the current workaround

🤖 Generated with Claude Code

…error

Add NSIS preinstall hook that terminates running Agent Workspace and node.exe
processes before the installer extracts files. This prevents the 'Error opening
file for writing' error on reinstall/update when the bundled node.exe is still
running and holding a file lock on itself.
Use PowerShell path filter to kill only node.exe running from the
agent-workspace install directory. Other Node.js processes are untouched.
@web3dev1337 web3dev1337 merged commit fad5813 into main Mar 20, 2026
5 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