mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(agents): add a machine-wide Playwright browser resource budget
Playwright disables normal background throttling, so a hidden 5chan page keeps doing P2P and rendering work after a check finishes. Agents verifying in parallel across worktrees stacked whole browser engines on one machine. Add scripts/pw-session.sh, a wrapper that permits one active Playwright browser at a time and records who holds it: - The lock is machine-wide, not per-repository, because the contended resource is RAM and CPU. Every worktree and checkout shares one slot. - Acquisition is an atomic mkdir. Stale locks clear themselves: `open` reclaims any slot whose recorded browser is no longer `status: open` in `playwright-cli list --all`, so an interrupted workflow cannot strand the budget. When that list cannot be read the lock is left alone, so a broken CLI never silently disables the budget. - `open` exits 75 when the slot is busy; `--wait[=SECONDS]` blocks instead. - `close` always stops the browser, even when the lock was already lost, and never releases a slot held by a different session. - `status` reports the holder and whether its browser is still alive. Agent policy now runs browser engines and profiler batches sequentially, uses Chrome/Blink during iteration and the full engine matrix only for final verification, and never uses `close-all` or `kill-all` while other agents may own sessions. Covered by scripts/pw-session.test.js.
This commit is contained in:
@@ -32,9 +32,11 @@ Since each `goto` creates a new document, data resets per route — collect **be
|
||||
Open a blank page, inject instrumentation via `addInitScript` (runs before any page script in every new document), then navigate:
|
||||
|
||||
```bash
|
||||
playwright-cli -s=SESSION open about:blank
|
||||
./scripts/pw-session.sh open SESSION about:blank
|
||||
```
|
||||
|
||||
If the wrapper exits 75 another browser workflow owns the slot. Block on `./scripts/pw-session.sh open --wait <session> about:blank`, or report that to the parent and stop. Never bypass the lock.
|
||||
|
||||
```bash
|
||||
playwright-cli -s=SESSION run-code "async page => await page.addInitScript(() => {
|
||||
window.__PROFILING__=true;
|
||||
@@ -95,7 +97,7 @@ playwright-cli -s=SESSION console error
|
||||
playwright-cli -s=SESSION console warning
|
||||
playwright-cli -s=SESSION network
|
||||
playwright-cli -s=SESSION tracing-stop
|
||||
playwright-cli -s=SESSION close
|
||||
./scripts/pw-session.sh close SESSION
|
||||
```
|
||||
|
||||
### Step 4: Analyze and Report
|
||||
@@ -168,6 +170,7 @@ Routes profiled: /route1, /route2, ...
|
||||
- If `__getReactScanReport` is undefined or returns `{}`, wait ~1s and retry once (it is a dynamic import); if still empty, note "react-scan report unavailable" and rely on commit counts
|
||||
- If a route has no content or fails to load, note it in Info and move on
|
||||
- **Always stop tracing and close the browser when done, even on errors** — wrap your workflow in a try/finally mindset: if any step fails, still run `tracing-stop` and `close`
|
||||
- Never use `playwright-cli close-all` or `kill-all`; they can terminate another agent's session
|
||||
- Board codes (`biz`, `pol`, `g`, etc.) map to community addresses via the app's directory
|
||||
- High commit counts without long tasks = frequent cheap rerenders — still worth fixing for efficiency
|
||||
- React-scan report pinpoints exact components — prioritize these in recommendations
|
||||
|
||||
Reference in New Issue
Block a user