fix(lsp): cleanup subprocess on failed initialization in StdioTransport.start() #11160

Closed
HAL9000 wants to merge 2 commits from pr-fix-10597 into master

2 Commits

Author SHA1 Message Date
freemo f0d2db692a fix(lsp): fix transport coverage BDD step for post-popen logger mock
CI / push-validation (pull_request) Successful in 47s
CI / helm (pull_request) Successful in 58s
CI / build (pull_request) Successful in 1m8s
CI / lint (pull_request) Failing after 1m29s
CI / typecheck (pull_request) Successful in 1m36s
CI / quality (pull_request) Successful in 2m3s
CI / security (pull_request) Successful in 2m38s
CI / integration_tests (pull_request) Successful in 7m6s
CI / unit_tests (pull_request) Successful in 9m43s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 6s
Patch the already-instantiated transport.logger.info directly instead
of patching structlog.get_logger(), which takes effect too late after
module-level import. Targeted exception-raising scope to only the
'lsp.transport.started' message so downstream stop() logging (stopping,
stopped) succeeds and allows cleanup to complete. Also removed unused
variable 'original_get_logger' that triggered F841 lint error.

ISSUES CLOSED: #7044
2026-05-13 00:15:17 +00:00
HAL9000 ed69291417 fix(lsp): cleanup subprocess on failed initialization in StdioTransport.start()
CI / helm (pull_request) Successful in 41s
CI / build (pull_request) Successful in 1m8s
CI / lint (pull_request) Failing after 1m29s
CI / typecheck (pull_request) Successful in 1m51s
CI / quality (pull_request) Successful in 1m49s
CI / security (pull_request) Successful in 1m51s
CI / push-validation (pull_request) Successful in 22s
CI / integration_tests (pull_request) Successful in 4m55s
CI / unit_tests (pull_request) Failing after 5m4s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / status-check (pull_request) Failing after 4s
After Popen succeeds, any exception in post-Popen code (e.g. logger.info)
would leave the spawned process running untracked — a resource leak.
The change wraps the post-Popen logger.info call in a try/except that calls
stop() to clean up the process before re-raising.

Two new Behave scenarios added:
  - "ltcov start cleans up subprocess when post-popen logging fails"
  - "ltcov start does not leak process when post-pogen succeeds normally"

Closes #7044
2026-05-12 17:17:42 +00:00