Repository navigation
fix(ports): report a Stop as succeeded when the listener already exited - #15888
Conversation
|
Warning Review limit reached
Next review available in: 12 minutes Limit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`killWorkspacePort` surfaced the raw `kill ESRCH` when the pid exited between the authorizing re-scan and the signal. The port is free at that point -- which is exactly what Stop was asked for -- so the UI reported a failure for work that had already completed. Also pins the pid we signal: `netstat -ano` and `lsof` report the process that owns the socket, so the scanned pid is the listener itself, not a supervising wrapper. Escalating this to a tree kill would reach descendants nobody asked to stop without freeing anything extra.
It blocks the calling thread for the full watchdog budget plus margin (5.2s) and then asserts against vitest's 5s default, so it has been failing deterministically since #12217.
87638b1 to
323404d
Compare
…ed (stablyai#15888) * fix(ports): report a Stop as succeeded when the listener already exited `killWorkspacePort` surfaced the raw `kill ESRCH` when the pid exited between the authorizing re-scan and the signal. The port is free at that point -- which is exactly what Stop was asked for -- so the UI reported a failure for work that had already completed. Also pins the pid we signal: `netstat -ano` and `lsof` report the process that owns the socket, so the scanned pid is the listener itself, not a supervising wrapper. Escalating this to a tree kill would reach descendants nobody asked to stop without freeing anything extra. * test(ports): give the spawn-stall test a budget longer than the stall It blocks the calling thread for the full watchdog budget plus margin (5.2s) and then asserts against vitest's 5s default, so it has been failing deterministically since stablyai#12217. (cherry picked from commit 84659e2)
…ed (stablyai#15888) * fix(ports): report a Stop as succeeded when the listener already exited `killWorkspacePort` surfaced the raw `kill ESRCH` when the pid exited between the authorizing re-scan and the signal. The port is free at that point -- which is exactly what Stop was asked for -- so the UI reported a failure for work that had already completed. Also pins the pid we signal: `netstat -ano` and `lsof` report the process that owns the socket, so the scanned pid is the listener itself, not a supervising wrapper. Escalating this to a tree kill would reach descendants nobody asked to stop without freeing anything extra. * test(ports): give the spawn-stall test a budget longer than the stall It blocks the calling thread for the full watchdog budget plus margin (5.2s) and then asserts against vitest's 5s default, so it has been failing deterministically since stablyai#12217.
…ed (stablyai#15888) * fix(ports): report a Stop as succeeded when the listener already exited `killWorkspacePort` surfaced the raw `kill ESRCH` when the pid exited between the authorizing re-scan and the signal. The port is free at that point -- which is exactly what Stop was asked for -- so the UI reported a failure for work that had already completed. Also pins the pid we signal: `netstat -ano` and `lsof` report the process that owns the socket, so the scanned pid is the listener itself, not a supervising wrapper. Escalating this to a tree kill would reach descendants nobody asked to stop without freeing anything extra. * test(ports): give the spawn-stall test a budget longer than the stall It blocks the calling thread for the full watchdog budget plus margin (5.2s) and then asserts against vitest's 5s default, so it has been failing deterministically since stablyai#12217.
What #10346 claimed, and why it is not right
The scan does not attribute the port to a wrapper.
scanWindowsNetstatPortsreadsnetstat -anoand takes the PID column (local-workspace-port-scanner.ts:245-263), and that column is the process owning the TCP endpoint — the listener itself. The POSIX path takes the same field fromlsof. Soprocess.kill(pid, 'SIGTERM')already targets the right process, and a tree kill would only add descendants nobody asked to stop.#10150 is also not this code path. It reports a dev server surviving project close / terminal exit, not the Resource Manager Stop button. That is PTY teardown, and it is what the job objects in #15755 / #15886 address.
The real defect
The authorizing re-scan runs first, then the signal. If the listener exits in between — common for a dev server the user just Ctrl-C'd elsewhere —
process.killthrowsESRCHand the UI reports failure for a port that is now free, which is exactly the outcome Stop asked for.ESRCHis now success. Every other error still fails, with its message.Tests
ESRCH→{ ok: true }EPERM→ still{ ok: false, reason }Drive-by
src/main/ports/port-scan-command-execution.test.tsblocks the calling thread for the full watchdog budget plus margin (5.2s) and asserts against vitest's 5s default. It has been failing deterministically since #12217; given a real budget it passes.Risk
None identified. One error code changes classification; no process that was not already being signalled is signalled now.
Credit to @innocarpe (#10346) for surfacing the Stop path, with the correction above.