Skip to content

SDK drift: Python ServerManager kills orphan sidecar processes before spawning; TypeScript ServerManager does not #1140

Description

@realfishsam

Summary

The Python ServerManager.ensure_server_running() calls _kill_orphan_sidecars() before spawning a new sidecar. TypeScript has no equivalent step.

Python (sdks/python/pmxt/server_manager.py, lines 111–117):

# Step 3: Kill orphan sidecars so the new one can bind the default port
self._kill_orphan_sidecars()

# Step 4: Start server via launcher
self._start_server_via_launcher()

_kill_orphan_sidecars (lines 259–298) uses pgrep -f 'pmxt.*bundled[.]js' on POSIX and wmic on Windows to enumerate and SIGTERM every orphaned sidecar process, then waits 500 ms before the new spawn.

TypeScript (sdks/typescript/pmxt/server-manager.ts, doEnsureServerRunning, lines 177–237):

No orphan-killing step exists. The sequence goes:

  1. (optional) kill old server if PMXT_ALWAYS_RESTART
  2. Check isServerRunning
  3. (optional) kill old server if version mismatch
  4. Spawn via pmxt-ensure-server
  5. waitForServer

Impact

On machines where a previous Node/Python process exited without stopping its detached sidecar, the TypeScript SDK may fail to start a new sidecar because the orphan occupies the default port (3847). The Python SDK recovers from this automatically; the TypeScript SDK does not, leaving users with port-in-use errors that are hard to diagnose.

Expected behaviour

Both SDKs should either (a) kill orphan processes before spawning, or (b) consistently rely on pmxt-ensure-server itself to handle port conflicts.

Files

SDK File Lines
Python sdks/python/pmxt/server_manager.py 111, 259–298
TypeScript sdks/typescript/pmxt/server-manager.ts 177–237

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions