Skip to content

fix(serve): skip an idle reap whose timer a launch has since re-armed - #93

Merged
tenequm merged 2 commits into
mainfrom
fix/pool-polish-review
Sep 19, 2026
Merged

tenequm merged 2 commits into
mainfrom
fix/pool-polish-review

Conversation

@tenequm

@tenequm tenequm commented Sep 19, 2026

Copy link
Copy Markdown
Member

Follow-up review of the idle-reap and pin-gate changes that landed in #86.

Stale idle reap

#86 made idleReap hold the seed launch lock until the profile dir is gone. That part is right. But the reap is a time.AfterFunc callback, so a timer that fires while a getOrLaunch holds the lock now queues on it and runs as soon as the launch releases the lock. Two cases:

  • Running browser: getOrLaunch re-arms the timer, which is a no-op Stop on a timer that has already fired, and returns the browser. The queued reap then finds conns == 0, because serveWS calls connect() only after websocket.Accept. So it tears down the browser that was just handed out.
  • Dead browser: getOrLaunch relaunches it. The queued reap then finds the new instance in processes, captures it over the stored snapshot, terminates it, deletes its profile and drops its secrets. Before fix(serve): pool-mode reaping, capture tab, hung tabs and launch bursts #86 the reap never waited on the lock, so it could not reach a fresh instance.

Either way the reap also deleted the re-armed timer's map entry without stopping that timer. connect() could then no longer cancel it.

Fix: the reap now runs only while its own timer is still the armed one. It checks under p.mu, after taking the seed lock. Any re-arm, cancel, relaunch or connect since the timer fired turns the reap into a no-op. It also drops the seed's secrets before retiring its lock, so a caller that creates the fresh lock cannot race that step.

TestStaleReapSparesAHandedOutBrowser fails on main and passes here.

Gated frame from a departed client

When a client leaves while its frame waits on a pin gate, the frame is now dropped before preprocessClient. Previously a keep-alive tab close in that frame still opened a replacement tab through replaceKeepAlive(ctx, ...), and nobody would use that tab.

Also

Fixed three stale or wrong comments: the seedLock name, secretStore.put's documented return value, and a half-reflowed paragraph.

Verification

  • just check passes.
  • go test -race -count=5 ./internal/serve/ passes.
  • The fingerprint golden is unchanged.
  • Ran a live pool-mode container (--idle-timeout=5) built from this branch. For each of three seeds:
    1. Set a cookie, then disconnect.
    2. Relaunch the same seed the moment the reap starts. The relaunch waits out the reap.
    3. The new Chrome comes up in an intact profile, with the cookie re-injected.
    4. It stays alive with a client attached.
    5. After the client leaves, it is reaped normally.

Release notes

Pool mode no longer kills a browser it has just handed to a client when an idle timeout fires at the same moment as a connect, and a relaunch of a crashed seed is no longer torn down right after it starts.

An idle timer that fired while a launch held the seed lock ran its reap as
soon as the launch let go, and tore down the browser just handed to a client
that had not connected yet - a freshly relaunched one included - then deleted
the re-armed timer's entry so connect could no longer cancel it. The reap now
acts only while its own timer is still the armed one, and drops the seed's
secrets before retiring its lock.
A client that left while its frame waited on a pin gate still had the frame preprocessed, and a keep-alive tab close from it opened a replacement tab nobody would use.
@tenequm
tenequm merged commit c667868 into main Sep 19, 2026
9 checks passed
@tenequm
tenequm deleted the fix/pool-polish-review branch September 19, 2026 00:24
tenequm added a commit that referenced this pull request Sep 21, 2026
🤖 I have created a release *beep* *boop*
---


## [0.15.0](v0.14.2...v0.15.0)
(2026-09-21)


### Features

* bundle playwright-cli into the image with a cuttle pw passthrough
([#67](#67))
([28d9846](28d9846))
* **cli:** center the skill and briefing on cuttle pw, drop host driver
routing ([#75](#75))
([33eca16](33eca16))
* **cli:** colored jev-browse output
([#70](#70))
([cf6f109](cf6f109))
* **cli:** cuttle jev-browse - autonomous browsing loop on the bundled
driver ([#66](#66))
([0496957](0496957))
* **cli:** deliver pw action snapshots as a host file, secrets masked
([#103](#103))
([78adbbb](78adbbb))
* **cli:** make --context/--name global so pw and jev-browse reach any
instance ([#74](#74))
([9df5c33](9df5c33))
* **cli:** zero-ceremony cuttle pw - auto-attach on demand, allow open
([a7e6491](a7e6491))
* **jev:** withhold write actions and halve jev-browse run time
([#102](#102))
([9ca9386](9ca9386))
* **serve:** mask password field values in /snapshot
([#109](#109))
([2a352b5](2a352b5))
* **serve:** session lease - one driver at a time, with takeover
([#69](#69))
([87724c8](87724c8))


### Bug Fixes

* **backend:** keep profile cleanup and remote argv from reaching past
their own ([#92](#92))
([f52cfd3](f52cfd3))
* **cli:** close the gaps a review of the lifecycle fixes found
([#90](#90))
([c46aa5e](c46aa5e))
* **cli:** close the lifecycle gaps a stress run left open
([#88](#88))
([899a535](899a535))
* **cli:** discarding the profile removes the instance's host snapshot
dir ([#113](#113))
([57cd07a](57cd07a))
* **cli:** downloads --wait accepts a finished download, logs drops
D-Bus spam ([#111](#111))
([dcc2f46](dcc2f46))
* **cli:** name the in-page dialog behind a pw click timeout
([#99](#99))
([11beeeb](11beeeb))
* **cli:** never fall back to another instance when the selected one is
stopped ([#78](#78))
([a1df361](a1df361))
* **cli:** re-attach the driver after a restart leaves a stale session
([#77](#77))
([bbeb0f0](bbeb0f0))
* **cli:** run --extract on every ending, not only done
([#71](#71))
([4954195](4954195))
* **jev:** judge done on the page that landed, and end done on a none
above even odds ([#108](#108))
([a9cb5a8](a9cb5a8))
* **jev:** offer filter-apply controls the write gate withheld
([#114](#114))
([bdf440a](bdf440a))
* **jev:** read quoted snapshot lines and keep field values out of
--extract ([#89](#89))
([09111a2](09111a2))
* **pw:** compact find output, downloads into a directory, quieter logs
([#116](#116))
([62f2ca8](62f2ca8))
* **pw:** snapshot links a host file like an action, and the console log
line names its verb
([#110](#110))
([c902c58](c902c58))
* **serve:** dismiss a native dialog the driver leaves open
([#87](#87))
([14f24cb](14f24cb))
* **serve:** keep the default seed's downloads across browser relaunch
([aac8e40](aac8e40))
* **serve:** keep the dialog watch alive through a signal shutdown
([#94](#94))
([4f4f1d0](4f4f1d0))
* **serve:** pool-mode reaping, capture tab, hung tabs and launch bursts
([#86](#86))
([3b42ea2](3b42ea2))
* **serve:** skip an idle reap whose timer a launch has since re-armed
([#93](#93))
([c667868](c667868))
* **smoke:** never exec into a container the run was not pointed at
([#79](#79))
([9075244](9075244))
* **viewer:** keep websocket inside proxy prefix
([#62](#62))
([3b10ba7](3b10ba7))


### Performance Improvements

* **cli:** run a pw verb in one docker exec, lease check included
([#100](#100))
([a9c3c90](a9c3c90))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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