Skip to content

fix(python): close browser server on launcher shutdown - #684

Open
Cloudymap1e wants to merge 1 commit into
daijro:mainfrom
Cloudymap1e:fix/server-graceful-shutdown
Open

fix(python): close browser server on launcher shutdown#684
Cloudymap1e wants to merge 1 commit into
daijro:mainfrom
Cloudymap1e:fix/server-graceful-shutdown

Conversation

@Cloudymap1e

Copy link
Copy Markdown

Related Issue

Closes #172

Description

The Python server launcher previously closed stdin immediately after sending configuration, while the Node process then used that same stream only as a keepalive. That prevented stdin EOF from representing controller shutdown and left BrowserServer cleanup dependent on abrupt process termination.

Python now sends one newline-delimited base64 configuration frame and keeps the pipe open. The Node launcher parses exactly that first frame, latches early stream termination, and treats later stdin end, close, or error as a shutdown request. It closes BrowserServer before exiting so Playwright can remove its temporary profile. The Python side closes the control pipe and reaps the child with bounded terminate/kill fallbacks for interruptions during write, flush, or wait.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Other

Testing

  • python -m pytest pythonlib/tests/test_server.py -q: 8 passed
  • python -m pytest pythonlib/tests -q: 48 passed, 4 skipped
  • node --check pythonlib/camoufox/launchServer.js: passed
  • The focused tests use real Node subprocesses to cover split/combined framing, first-frame-only parsing, clean EOF, close-only termination, stream errors, BrowserServer close completion, and interrupted Python write/flush cleanup

Fingerprint Report

Not applicable: this changes the Python/Node server lifecycle and does not alter fingerprint behavior.

Checklist

  • I have linked a related issue above
  • My changes are focused on a single logical change
  • I have added testing instructions which include the desired result
  • Service tests pass (for python library changes) -./service-tester/run_tests.sh --browser-version official/prerelease/146.0.1-alpha.25 (attach screenshot) temporarily out of service lol
  • Build test passes (for patch changes) - not applicable to this server-lifecycle change

@JWriter20 JWriter20 mentioned this pull request Jul 30, 2026
5 tasks
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.

Python Remote Server Graceful Shutdown

1 participant