| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
server.stop() after await new Promise(() => {}) is unreachable dead code.
No signal handlers exist, so SIGTERM/SIGINT use the kernel default and
Instance.disposeAll() never runs — orphaning MCP subprocesses, LSP servers,
file watchers, and SQLite connections.
Add signal handlers following the existing pattern from worker.ts:137-147:
timeout-bounded Instance.disposeAll() + server.stop(true) + process.exit(0).
clearInterval(heartbeat) and unsub() only run inside stream.onAbort(), which Hono only fires on client disconnect. When the server closes the stream on InstanceDisposed via stream.close(), the interval and bus subscription leak. Add cleanup before stream.close() in the InstanceDisposed handler. Both calls are idempotent so the onAbort fallback for normal client disconnects still works.
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
What does this PR do?
Fixes #14091
Two resource cleanup bugs in the serve/web commands and the SSE event endpoint:
serve.ts and web.ts — server.stop() is dead code (unreachable after await new Promise(() => {})), and no signal handlers exist. On SIGTERM/SIGINT, Instance.disposeAll() never runs, so MCP subprocesses, LSP servers, and other child resources are orphaned.
server.ts — The SSE /event endpoint puts clearInterval(heartbeat) and unsub() inside stream.onAbort(), which Hono only calls on client disconnect. When the server closes the stream on InstanceDisposed via stream.close(), cleanup never runs and the interval + subscription leak.
Changes
serve.ts and web.ts — Add signal handlers following the existing pattern from worker.ts:137-147:
server.ts — Add clearInterval(heartbeat) and unsub() to the InstanceDisposed handler before stream.close(). Both calls are idempotent, so the existing onAbort handler remains as a fallback for normal client disconnects.
How did you verify your code works?