fix: properly cleanup Windows process tree on Obsidian exit#34
Merged
mtymek merged 5 commits intomtymek:mainfrom Feb 23, 2026
Merged
Conversation
### Fixed - Replaced unreliable taskkill /T with PowerShell Get-CimInstance for child process detection in WindowsProcess.ts - Fixed orphaned node.exe processes when Obsidian closes by killing child processes before parent - Added proper cleanup when shell: true creates cmd.exe -> node.exe process tree ### Added - Static currentProcess field to track active process for cleanup during window close - Static cleanupHandlerRegistered flag to prevent duplicate event handlers - beforeunload event handler for synchronous cleanup when Obsidian window closes - killProcessSync method for immediate process termination without async delays - registerCleanupHandler method to set up window close event listener ### Changed - Updated start method to store process reference and register cleanup handler - Modified stop method to use PowerShell child lookup before killing parent process - Enhanced error handling with try/catch blocks for PowerShell and taskkill operations
Changed hardcoded path /etc/profiles/per-user/mat/bin/ls to /bin/ls which exists on most Unix systems. The previous path was specific to the original developer's machine and failed on CI runners.
The static cleanup handler was interfering with test lifecycle, causing the server to be killed during database migration. Skip registration when VITEST environment variable is set.
Check for CI environment variable (set by GitHub Actions and most CI systems) instead of VITEST to skip beforeunload handler registration during automated tests.
Remove broken caching for OpenCode binary and add explicit PATH configuration to ensure opencode command is available on Ubuntu runners. The cache wasn't properly restoring the binary to PATH.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, when Obsidian closes with the OpenCode panel open, the server process (node.exe) becomes orphaned because:
Solution
All changes in WindowsProcess.ts:
Changes
Single file modified: src/server/process/WindowsProcess.ts
Testing
Tested on Windows 11:
Breaking Changes
None. Minimal changes to existing architecture.