Skip to content

Fix OpenCode process cleanup on Obsidian shutdown#68

Open
yangyangyanghub wants to merge 1 commit into
mtymek:mainfrom
yangyangyanghub:upstream/cleanup-opencode-process
Open

Fix OpenCode process cleanup on Obsidian shutdown#68
yangyangyanghub wants to merge 1 commit into
mtymek:mainfrom
yangyangyanghub:upstream/cleanup-opencode-process

Conversation

@yangyangyanghub

Copy link
Copy Markdown

Summary

This fixes an issue where opencode serve can remain running after Obsidian exits, especially on Windows.

The previous Windows cleanup only killed the parent process and direct child processes. Because the plugin starts OpenCode through a shell, the actual opencode.exe server process can remain orphaned and keep listening on the configured port.

Changes

  • Use taskkill /F /T /PID on Windows to terminate the full process tree.
  • Add synchronous shutdown cleanup via stopSync.
  • Use synchronous cleanup during Obsidian quit.
  • Avoid showing stop notices during unload/restart cleanup.
  • Keep the existing safety boundary: the plugin only stops processes it started and does not kill by port or process name.

Verification

  • Built successfully with:
    • bun run tsc -noEmit -skipLibCheck --ignoreDeprecations 5.0
    • bun run esbuild.config.mjs production
  • Manually verified in Obsidian on Windows:
    • Start OpenCode server from the plugin.
    • Close Obsidian.
    • Confirm the configured port is released and no plugin-started opencode serve process remains.

🤖 Generated with Claude Code

Use synchronous shutdown cleanup and terminate Windows process trees so plugin-started opencode serve processes do not remain after Obsidian exits.

Co-authored-by: Admin <wuyang0128@foxmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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