Skip to content

Stealth Chromium that passes every bot detection test. Drop-in Playwright replacement with source-level fingerprint patches. 50+ tests passed.

fix(cloakserve): reset the exit-after-idle clock when a browser is opened

CloakHQ008e0c503ea2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f2f1a8..84f78af 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,10 @@ Changes are tagged: **[wrapper]** for Python/JS wrapper, **[binary]** for Chromi
## [Unreleased]
-- **[wrapper]** `cloakserve --exit-after-idle=SECONDS` (or `CLOAKSERVE_EXIT_AFTER_IDLE`) shuts the server down with exit status 0 once no CDP connection has been open for that long, so a per-job container stops when its work is done (#572)
+- **[wrapper]** `cloakserve --exit-after-idle=SECONDS` (or `CLOAKSERVE_EXIT_AFTER_IDLE`) shuts the server down with exit status 0 once no CDP connection has been open for that long, so a per-job container stops when its work is done (#572, #616)
+- **[wrapper]** `cloakserve --keep-profiles` keeps each seed's profile under `--data-dir` when its Chrome process is cleaned up, so reopening the seed restores its cookies and logins
+- **[wrapper]** `cloakserve` now stops Chrome with SIGINT instead of SIGTERM on Linux and macOS, so cookies set just before cleanup are written to disk, and waits up to 10s before force-killing it so the license session can end cleanly
+- **[wrapper]** `cloakserve` pings each CDP client every 30 seconds and drops one that stops answering, so a client that vanishes without closing its connection (network drop, dead host) no longer keeps its Chrome process alive (#412, #622)
## [0.6.4] — 2026-10-23
diff --git a/README.md b/README.md
index 6b0b8e2..b4ae30f 100644
--- a/README.md
+++ b/README.md
@@ -963,6 +963,10 @@ docker run -d --name cloak -p 127.0.0.1:9222:9222 cloakhq/cloakbrowser \
# Keep per-seed profiles (cookies, logins) across idle cleanup and container restarts
docker run -d --name cloak -p 127.0.0.1:9222:9222 -v ./cloak-profiles:/profiles cloakhq/cloakbrowser \
cloakserve --idle-timeout=300 --data-dir=/profiles --keep-profiles
+
+# Per-job container: reap Chrome 60s after disconnect, exit (status 0) after 5 minutes with no connections
+docker run --rm --name cloak -p 127.0.0.1:9222:9222 cloakhq/cloakbrowser \
+ cloakserve --idle-timeout=60 --exit-after-idle=300
```
Stop the server:
@@ -1375,10 +1379,11 @@ Issues and PRs welcome. If something isn't working, [open an issue](https://gith
- [@ishiko732](https://github.com/ishiko732) — HTTP proxy credentials in GeoIP resolution
- [@Shub3am](https://github.com/Shub3am) — horizontal scroll-into-view for humanized clicks, safe concurrent first-run downloads
- [@dstosch](https://github.com/dstosch) — cloakserve idle cleanup for browsers launched over HTTP
-- [@bercedev](https://github.com/bercedev) — humanize support for compiled (Nuitka) Playwright builds
+- [@bercedev](https://github.com/bercedev) — humanize support for compiled (Nuitka) Playwright builds, cloakserve exit after idle
- [@laplace-anon](https://github.com/laplace-anon) — humanize fix for Playwright 1.64
- [@theaafofficial](https://github.com/theaafofficial) — non-blocking async launches (GeoIP, WebRTC and license lookups off the event loop)
- [@jipeng6036-del](https://github.com/jipeng6036-del) — Seychelles GeoIP locale
+- [@pujitha24](https://github.com/pujitha24) — cloakserve WebSocket heartbeat for vanished clients
## Star History
diff --git a/bin/cloakserve b/bin/cloakserve
index 0b3a80e..0eb17f5 100755
--- a/bin/cloakserve
+++ b/bin/cloakserve
@@ -303,6 +303,9 @@ class ChromePool:
geoip: bool = False,
) -> ChromeProcess:
"""Get existing or launch new Chrome process for a seed."""
+ # Clients open the browser before their WebSocket connects; without this
+ # --exit-after-idle can fire in that gap and cut the client off mid-launch.
+ self._last_activity = time.monotonic()
# Apply CLI defaults when query params don't provide values
if seed is None and self._default_seed:
seed = self._default_seed
diff --git a/tests/test_cloakserve.py b/tests/test_cloakserve.py
index a25f5b4..62c5119 100644
--- a/tests/test_cloakserve.py
+++ b/tests/test_cloakserve.py
@@ -562,6 +562,20 @@ class TestConnectionTracking:
asyncio.run(run())
+ def test_get_or_launch_resets_exit_after_idle_clock(self):
+ # A client opens the browser (/json/version) before its WebSocket connects;
+ # the idle exit must not fire in that gap and cut the client off.
+ async def run():
+ pool = self._make_pool()
+ pool._processes["12345"] = SimpleNamespace(
+ process=SimpleNamespace(poll=lambda: None), cdp_port=1,
+ )
+ pool._last_activity = 0.0
+ await pool.get_or_launch(seed="12345")
+ assert _mod.time.monotonic() - pool._last_activity < 1
+
+ asyncio.run(run())
+
def test_idle_cleanup_disabled_by_default(self):
async def run():
pool = self._make_pool()