Skip to content

chore(embed): tidy detach-popen helper and close log fds in parent#1418

Merged
nicoloboschi merged 2 commits intomainfrom
cleanup/daemon-detach-popen-tidy
May 4, 2026
Merged

chore(embed): tidy detach-popen helper and close log fds in parent#1418
nicoloboschi merged 2 commits intomainfrom
cleanup/daemon-detach-popen-tidy

Conversation

@nicoloboschi
Copy link
Copy Markdown
Collaborator

Summary

Follow-up cleanup to #1380 (which made the daemon redirect stdout/stderr to a log file on POSIX, fixing TUI corruption).

  • Drop the dead log_handle is None branch in _detach_popen_kwargs. After fix: redirect daemon subprocess stdout/stderr on POSIX to prevent TUI corruption #1380, both call sites always pass a handle, so the inherit-fd branch is unreachable. Type the parameter as IO[bytes] and trim the docstring to match reality.
  • Close the parent's copy of the log fd. Wrap both the daemon spawn (_start_daemon_locked) and the UI spawn (start_ui) in with open(...) blocks. Popen dups the fd into the child during spawn, so the parent's handle is dead weight after Popen returns — closing it stops the small per-spawn fd leak that pre-existed both PRs.
  • Add a regression test for the fix: redirect daemon subprocess stdout/stderr on POSIX to prevent TUI corruption #1380 fix. test_posix_popen_redirects_stdout_stderr_to_log asserts that on POSIX the daemon's stdout/stderr go to a real file handle (not None/inherited). The previous regression had no test guarding it.

No behavior change for end users — purely tidy-up plus a guardrail.

Test plan

  • uv run pytest tests/test_profile_daemon_config.py tests/test_daemon_client.py (26 passed)
  • ./scripts/hooks/lint.sh (clean)
  • CI green

Follow-up to #1380. With the POSIX inherit-fd path gone, `log_handle` is
always supplied — drop the dead `None` branch in `_detach_popen_kwargs`,
type the parameter, and refresh the docstring. Wrap the daemon and UI
log opens in `with` blocks so the parent's copy of the fd is released
once Popen has dup'd it into the child. Add a regression test that
locks down POSIX stdout/stderr redirection so future refactors don't
silently re-introduce the TUI-corruption regression.
- Drop trailing commas in api.ts that the project formatter rewrites.
- Refresh uv.lock to resolve opentelemetry-* against the raised floors
  introduced in #1373 (`1.41.0` / `0.62b1`).

Both fall out of running `./scripts/hooks/lint.sh` on a clean checkout
and are unrelated to the embed-detach cleanup in this PR — bundling
them so the working tree stays clean after lint.
@nicoloboschi nicoloboschi merged commit 10210ba into main May 4, 2026
liling pushed a commit to liling/hindsight that referenced this pull request May 5, 2026
…ectorize-io#1418)

* chore(embed): tidy detach-popen helper and close log fds in parent

Follow-up to vectorize-io#1380. With the POSIX inherit-fd path gone, `log_handle` is
always supplied — drop the dead `None` branch in `_detach_popen_kwargs`,
type the parameter, and refresh the docstring. Wrap the daemon and UI
log opens in `with` blocks so the parent's copy of the fd is released
once Popen has dup'd it into the child. Add a regression test that
locks down POSIX stdout/stderr redirection so future refactors don't
silently re-introduce the TUI-corruption regression.

* chore: apply pending lint formatter and uv.lock sync

- Drop trailing commas in api.ts that the project formatter rewrites.
- Refresh uv.lock to resolve opentelemetry-* against the raised floors
  introduced in vectorize-io#1373 (`1.41.0` / `0.62b1`).

Both fall out of running `./scripts/hooks/lint.sh` on a clean checkout
and are unrelated to the embed-detach cleanup in this PR — bundling
them so the working tree stays clean after lint.
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