openclaw - ✅(Solved) Fix [Bug]: Bundled LSP tsserver processes can remain after Gateway stop [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#72357Fetched 2026-04-27 05:31:01
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
cross-referenced ×2labeled ×2commented ×1

Bundled LSP cleanup could leave nested tsserver child processes running after the OpenClaw Gateway stopped.

Root Cause

Bundled LSP cleanup could leave nested tsserver child processes running after the OpenClaw Gateway stopped.

Fix Action

Fixed

PR fix notes

PR #72367: fix: clean up bundled LSP process trees on shutdown

Description (problem / solution / changelog)

Summary

  • Problem: Bundled stdio LSP servers could leave nested child processes such as tsserver running after run cleanup or Gateway shutdown.
  • Why it matters: Orphaned language-server children can keep consuming memory after OpenClaw has stopped or restarted.
  • What changed: Bundle LSP servers now spawn as disposable process groups, cleanup terminates the process tree, and Gateway shutdown sweeps active bundle LSP runtimes with bounded grace handling.
  • What did NOT change (scope boundary): No plugin manifest format, LSP tool schema, model/provider routing, or user config behavior changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #72357
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: Bundle LSP disposal only terminated the immediate LSP process, and Gateway shutdown did not have a global active bundle-LSP runtime sweep.
  • Missing detection / guardrail: There was no regression test proving nested LSP process trees are terminated or that Gateway shutdown invokes bundle-LSP cleanup.
  • Contributing context (if known): Existing Gateway shutdown already swept bundle MCP runtimes, but bundle LSP runtimes were per-run only.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/pi-bundle-lsp-runtime.test.ts, src/gateway/server-close.test.ts
  • Scenario the test should lock in: Bundle LSP processes are spawned as disposable process groups, cleanup uses process-tree termination, and Gateway shutdown calls the active bundle-LSP sweep.
  • Why this is the smallest reliable guardrail: The bug is in local runtime lifecycle and Gateway shutdown plumbing, so mocked process and shutdown tests cover the failing contract without a live TypeScript server.
  • Existing test that already covers this (if any): None.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Stopping or restarting the Gateway now also cleans up active bundled LSP process trees, including nested children such as tsserver.

Diagram (if applicable)

Before:
[Gateway stop] -> [run/gateway cleanup] -> [immediate LSP process killed] -> [nested tsserver may remain]

After:
[Gateway stop] -> [bundle LSP shutdown sweep] -> [process tree terminated] -> [nested tsserver exits]

## Changed files

- `src/agents/pi-bundle-lsp-runtime.test.ts` (added, +141/-0)
- `src/agents/pi-bundle-lsp-runtime.ts` (modified, +108/-36)
- `src/gateway/server-close.test.ts` (modified, +59/-0)
- `src/gateway/server-close.ts` (modified, +34/-11)


---

# PR #72530: fix(lsp): kill entire process group on LSP session cleanup

- Repository: openclaw/openclaw
- Author: ottodeng
- State: open | merged: False
- Link: https://github.com/openclaw/openclaw/pull/72530

## Description (problem / solution / changelog)

## Summary

Fixes #72357 — bundled LSP `tsserver` child processes persist after gateway stop.

## Root cause

`typescript-language-server` spawns `tsserver` as a nested child process. The current cleanup code calls `session.process.kill()` which only sends SIGTERM to the direct child (`typescript-language-server`), leaving `tsserver` orphaned and consuming memory.

## Fix

1. **Spawn LSP processes in their own process group** (`detached: true` on Unix) so the entire tree can be addressed with a single signal
2. **Send SIGTERM to the process group** (`process.kill(-pid, 'SIGTERM')`) in `disposeSession()` before falling through to the direct `process.kill()`

On Windows, `ChildProcess.kill()` already terminates the process tree, so `detached` and negative-PID signaling are skipped.

## Changes

- `src/agents/pi-bundle-lsp-runtime.ts`: Added `detached: !isWindows` to spawn options; added process group kill in `disposeSession()`

## Testing

- TypeScript compilation passes with no errors
- Process group kill is wrapped in try/catch for robustness (group may already be gone)

## Changed files

- `src/agents/pi-bundle-lsp-runtime.test.ts` (added, +99/-0)
- `src/agents/pi-bundle-lsp-runtime.ts` (modified, +56/-1)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Bundled LSP cleanup could leave nested tsserver child processes running after the OpenClaw Gateway stopped.

Steps to reproduce

  1. Run OpenClaw with a bundled plugin that declares a stdio LSP server such as typescript-language-server --stdio.
  2. Start a Gateway run that activates bundled LSP tools.
  3. Stop or restart the Gateway.
  4. Check running processes with ps and observe tsserver processes still running after the Gateway has stopped.

Expected behavior

Stopping or restarting the Gateway terminates active bundled LSP runtimes, including nested child processes such as tsserver.

Actual behavior

tsserver processes were observed still running and consuming memory after the OpenClaw Gateway was stopped.

OpenClaw version

2026.4.26

Operating system

Ubuntu 24.04

Install method

Repo checkout / pnpm workspace. Node v22.22.1, pnpm 10.33.0.

Model

N/A - bundled LSP runtime cleanup path; no model request is required.

Provider / routing chain

N/A - no provider or model routing is involved.

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

TL;DR

The issue can be mitigated by implementing a proper cleanup mechanism for bundled LSP runtimes, ensuring that child processes like tsserver are terminated when the OpenClaw Gateway stops.

Guidance

  • Review the OpenClaw Gateway's shutdown procedure to ensure it properly terminates all active bundled LSP tools and their child processes.
  • Investigate the use of process management tools or APIs that can help track and terminate nested child processes like tsserver.
  • Modify the Gateway's stop/restart logic to include a step that explicitly kills any remaining tsserver processes.
  • Consider adding logging to track the lifecycle of bundled LSP runtimes and their child processes for easier debugging.

Example

No specific code example can be provided without more details on the OpenClaw Gateway's implementation, but a general approach might involve using process IDs (PIDs) to track and manage child processes.

Notes

The solution may require modifications to the OpenClaw Gateway's codebase, specifically in how it manages the lifecycle of bundled LSP runtimes and their child processes. The exact implementation details are not provided in the issue.

Recommendation

Apply a workaround by modifying the Gateway's shutdown logic to explicitly terminate tsserver processes, as the root cause seems to be related to the cleanup mechanism of the Gateway.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Stopping or restarting the Gateway terminates active bundled LSP runtimes, including nested child processes such as tsserver.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Bundled LSP tsserver processes can remain after Gateway stop [2 pull requests, 1 comments, 2 participants]