Skip to content

fix(stop-metro): only kill the listener (keep execFileSync, no shell)#364

Draft
latekvo wants to merge 1 commit into
mainfrom
fix/stop-metro-listen-keep-execfile
Draft

fix(stop-metro): only kill the listener (keep execFileSync, no shell)#364
latekvo wants to merge 1 commit into
mainfrom
fix/stop-metro-listen-keep-execfile

Conversation

@latekvo

@latekvo latekvo commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problem

stop-metro runs lsof -ti tcp:<port>, which returns every process with a socket on the port — including ESTABLISHED connections, not just the listener. The Argent tool-server holds a CDP client socket to Metro on that port, so stop-metro SIGTERMs the tool-server along with Metro (it then auto-respawns, dropping in-memory profiler session state and disrupting any connected editor).

Fix

Add -sTCP:LISTEN so only the process listening on the port (Metro) matches.

This keeps the existing execFileSync (no shell) call — port is never shell-interpreted, preserving the defense-in-depth in the original code.

Note: there is an existing branch fix/stop-metro-listener-only with the same -sTCP:LISTEN idea, but it switches to execSync with the port interpolated into a shell string. port is zod-validated to an int so it's safe in practice, but it reintroduces a shell surface the original deliberately avoided. This PR is the no-shell alternative — pick whichever you prefer.

Verification

Listener-vs-client repro: lsof -ti tcp:<port> returns both the listener and a connected client pid; lsof -ti tcp:<port> -sTCP:LISTEN returns only the listener.

…ed clients

lsof -ti tcp:<port> returns every process with a socket on the port,
including ESTABLISHED connections. The Argent tool-server holds a CDP
client socket to Metro on that port, so stop-metro SIGTERM'd the
tool-server along with Metro. Restrict the match with -sTCP:LISTEN so
only the process listening on the port (Metro) is killed.
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