@generativereality/browser-automation 0.4.13 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +3 -2
- package/LICENSE +21 -0
- package/README.md +10 -5
- package/dist/index.js +202 -13
- package/package.json +2 -2
- package/scripts/launch-chrome.sh +125 -19
- package/scripts/release.sh +189 -0
- package/scripts/sync-plugin.sh +37 -5
- package/skills/browser/SKILL.md +97 -334
- package/skills/browser/references/contributing.md +36 -0
- package/skills/browser/references/input-and-forms.md +137 -0
- package/skills/browser/references/renderer-health.md +213 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Input, forms and uploads — the hard cases
|
|
2
|
+
|
|
3
|
+
Reference for the `browser` skill. Read it when a click or fill "succeeds" but nothing
|
|
4
|
+
happens, a combobox needs real keystrokes, a hardware-2FA prompt never appears, a form
|
|
5
|
+
submits a stale value, or you need to upload a file. The short rules are in `SKILL.md`,
|
|
6
|
+
under Gotchas; this is the detail and the worked cases behind them.
|
|
7
|
+
|
|
8
|
+
## Keystrokes, and forms that swallow a dispatched click
|
|
9
|
+
|
|
10
|
+
- **There is NO way to send real keystrokes, and `fill --native` is not one.** `--native` uses CDP
|
|
11
|
+
`Input.insertText`, which fires `beforeinput`/`input` but **never `keydown`**. A combobox that
|
|
12
|
+
filters its list on keystrokes therefore stays empty: the value lands in the DOM and no options
|
|
13
|
+
ever render. npm’s "Select packages and scopes" picker is the canonical case (2026-08-22) — the
|
|
14
|
+
field showed `generativereality` and the list stayed blank through `fill`, `fill --native`, and a
|
|
15
|
+
React native-setter `eval`. There is no `press` or `type` command to escalate to.
|
|
16
|
+
⇒ Drop to raw CDP on the tab’s `webSocketDebuggerUrl` and dispatch `Input.dispatchKeyEvent`
|
|
17
|
+
per character. Two traps, both hit:
|
|
18
|
+
**(1) `keyDown` carrying `text` already inserts the character** — sending a `char` event as well
|
|
19
|
+
types everything twice (`ggeenneerraattiivvee…`), which reads as a flaky page rather than a double
|
|
20
|
+
dispatch. Send `keyDown` + `keyUp` only.
|
|
21
|
+
**(2) Clear with real Backspaces, not select-all+Delete.** A value written by a JS setter is
|
|
22
|
+
invisible to the component’s own state, so the framework keeps the old string and you end up
|
|
23
|
+
appending to it. Backspacing drives the same path a person would.
|
|
24
|
+
Also: the dropdown must actually be **open** first — typing into a collapsed picker’s hidden input
|
|
25
|
+
does nothing, and looks identical to the events not landing.
|
|
26
|
+
**Do NOT hand-roll a raw-CDP trusted click.** Burned 2026-08-22: wrote a
|
|
27
|
+
bespoke `Input.dispatchMouseEvent` helper for exactly this, and it clicked
|
|
28
|
+
stale coordinates (the panel had animated in) — `--trusted` already solves that
|
|
29
|
+
with the actionability wait. Check `browser-automation click --help` before
|
|
30
|
+
building anything.
|
|
31
|
+
**A form can swallow a dispatched click and submit itself the wrong way.**
|
|
32
|
+
npmjs.com's package-settings forms are the case (2026-08-22): a default click
|
|
33
|
+
on the submit button did not reach the framework's handler, so the browser fell
|
|
34
|
+
through to a plain native POST and the tab was replaced by a raw
|
|
35
|
+
`{"message":"Not Found"}` — no error from the CLI, and nothing saved. It looks
|
|
36
|
+
like the server rejected your data; it did not. `--trusted` submitted the same
|
|
37
|
+
form correctly. On any settings page, verify by reloading and re-reading the
|
|
38
|
+
saved state rather than trusting a click that "worked".
|
|
39
|
+
|
|
40
|
+
## WebAuthn / security keys
|
|
41
|
+
|
|
42
|
+
- **WebAuthn / security keys need a genuinely focused, visible tab, and you
|
|
43
|
+
cannot supply the touch.** `navigator.credentials.get()` refuses outright when
|
|
44
|
+
`document.hasFocus()` is false or `visibilityState` is `hidden` — which is the
|
|
45
|
+
normal state while you work in the terminal, since `--trusted` only fronts the
|
|
46
|
+
tab for the instant of the click. The prompt then never opens and the page just
|
|
47
|
+
sits there, so a 2FA step can look like it is waiting for the user when the
|
|
48
|
+
browser has already declined to ask. Measured 2026-08-22 on npm's
|
|
49
|
+
`Use security key` challenge: the form POST returned **200** and the challenge
|
|
50
|
+
was live, but it could only be satisfied once the user brought that Chrome
|
|
51
|
+
window to the front themselves. Check with
|
|
52
|
+
`eval '({f:document.hasFocus(),v:document.visibilityState})'` before concluding
|
|
53
|
+
anything, and hand hardware-2FA steps to the user with the window frontmost.
|
|
54
|
+
|
|
55
|
+
## Controlled-form state stickiness
|
|
56
|
+
|
|
57
|
+
- **Controlled-form state stickiness.** Form libraries that subscribe to React's
|
|
58
|
+
internal value-setter (React Hook Form, Final Form, Formik with a `Controller`,
|
|
59
|
+
Blocket/finn.no's `recommerce` editor) sometimes ignore the synthetic `input`
|
|
60
|
+
event the default `fill` dispatches: the DOM input shows the new value, but
|
|
61
|
+
the form's React state stays on the old one — and the next submit serializes
|
|
62
|
+
the *old* value. Two ways out:
|
|
63
|
+
1. **`fill --native --verify <ref> <value>`** — drives character insertion
|
|
64
|
+
through CDP `Input.insertText` (trusted events). `--verify` re-reads the
|
|
65
|
+
field afterwards and warns if either the DOM value diverged from what you
|
|
66
|
+
asked for, or if React's internal `_valueTracker` still holds the old
|
|
67
|
+
value (the canonical state-stickiness signature). Use this first; it
|
|
68
|
+
solves the vast majority of cases.
|
|
69
|
+
2. **API bypass** — when even `--native` doesn't stick (e.g. the form library
|
|
70
|
+
binds to an external state machine that drives its own POST/PUT), grab the
|
|
71
|
+
form's underlying endpoint and hit it directly:
|
|
72
|
+
```bash
|
|
73
|
+
# Hook fetch and persist a real form-submit's body + headers via localStorage
|
|
74
|
+
# (it survives the post-submit navigation, unlike window.* globals):
|
|
75
|
+
browser-automation eval -s app "(function(){var f=window.fetch;window.fetch=function(u,o){if(o&&o.method==='PUT'&&u.toString().includes('/api/item/')){localStorage.setItem('__lastPut',o.body||'');localStorage.setItem('__lastHdrs',JSON.stringify(o.headers||{}));}return f.apply(this,arguments);};})()"
|
|
76
|
+
# …then click Save once in the form so the hook captures the canonical PUT…
|
|
77
|
+
browser-automation eval -s app "({body:localStorage.getItem('__lastPut'),headers:localStorage.getItem('__lastHdrs')})"
|
|
78
|
+
# …gives you the endpoint, exact body shape, and custom headers
|
|
79
|
+
# (e.g. Blocket uses E-Tag, not the standard If-Match — and the etag lives
|
|
80
|
+
# in the JSON body, not the HTTP header).
|
|
81
|
+
```
|
|
82
|
+
Then re-fetch the GET endpoint for current data + the current etag, PUT
|
|
83
|
+
directly with the modified field(s) and the captured custom header, and
|
|
84
|
+
**drive the form's terminal commit step through the UI** — many two-step
|
|
85
|
+
editors (`edit → delivery → publish`) only persist `state: "edit"`
|
|
86
|
+
server-side until that final Save fires the commit.
|
|
87
|
+
|
|
88
|
+
Blocket's recommerce price field is the canonical case: default `fill e43 "500"`
|
|
89
|
+
shows 500 in the input but submits 750. Fix: `fill --native --verify e43 "500"`
|
|
90
|
+
(or, if --native doesn't stick: direct PUT to
|
|
91
|
+
`/recommerce/create/api/item/<id>` with `E-Tag: <body.etag>`, then click
|
|
92
|
+
Save on the delivery page to commit).
|
|
93
|
+
|
|
94
|
+
## File upload
|
|
95
|
+
|
|
96
|
+
- **File upload.** Three paths. The first two mirror Playwright. For a static, snapshot-able
|
|
97
|
+
`<input type=file>`, use `setfiles <ref> <path…>` — it resolves the ref and
|
|
98
|
+
calls `DOM.setFileInputFiles` (a file input's `.files` is read-only to page JS,
|
|
99
|
+
so a value-setter/`eval` can't populate it; CDP can, and fires trusted
|
|
100
|
+
`input`/`change`). For a **custom "attach" button** that opens a native file
|
|
101
|
+
chooser and reads a *transient* `<input type=file>` it creates+clicks on the fly
|
|
102
|
+
(App Store Connect's "Attach File", many React dropzones), `setfiles` on the
|
|
103
|
+
static input is useless — the handler uses its own throwaway input. Use
|
|
104
|
+
`upload --click <ref> <path…>`: it arms `Page.setInterceptFileChooserDialog`,
|
|
105
|
+
clicks the trigger, waits for `Page.fileChooserOpened`, and sets files on the
|
|
106
|
+
`backendNodeId` Chrome reports. Paths are resolved from cwd; pass absolute paths
|
|
107
|
+
to be safe. Multiple paths upload as a multi-file selection.
|
|
108
|
+
**Verify by re-snapshot/screenshot, and DON'T blindly retry.** Apps reset the
|
|
109
|
+
input to 0 right after consuming the file, so `upload` judges success by the
|
|
110
|
+
`change` event (it reports "delivered"), not by residual `input.files` — a
|
|
111
|
+
successful upload legitimately leaves `files=0`. The staged file often shows up
|
|
112
|
+
as a row in an attachment *list* (e.g. ASC's "Message Attachments"), not a single
|
|
113
|
+
chip, so confirm with `snapshot`/`screenshot` rather than assuming. Each
|
|
114
|
+
successful run **adds another attachment** — retrying a "did it work?" upload a
|
|
115
|
+
few times silently produces duplicates (this cost us a dozen copies on a live ASC
|
|
116
|
+
reply). Upload once, verify, and only re-run if verification shows nothing staged.
|
|
117
|
+
The **third path is drag-and-drop**, for zones with NO `<input type=file>` at
|
|
118
|
+
all — a `drop` listener reading `e.dataTransfer.files` (vocalremover-style audio
|
|
119
|
+
tools, many image/video drop zones). Neither `setfiles` nor `upload` applies;
|
|
120
|
+
use `drop <ref> <path…>`. By default it fires a genuinely-**trusted** CDP drag
|
|
121
|
+
(`Input.dispatchDragEvent`) carrying the real files from disk: it force-fronts
|
|
122
|
+
the tab (bringToFront + focus emulation + active lifecycle — so the tab reports
|
|
123
|
+
focused+visible even when the Chrome window isn't the frontmost OS window),
|
|
124
|
+
waits for the zone to be actionable, then dragEnter→dragOver→drop. The
|
|
125
|
+
force-front matters: drop-zone uploaders commonly do their work only inside a
|
|
126
|
+
**user activation**, and CDP input grants no activation on a tab the renderer
|
|
127
|
+
considers `hidden` — which it is whenever the window is occluded (the usual
|
|
128
|
+
case while you work in the terminal). vocalremover.org is the canonical example:
|
|
129
|
+
the file reaches its `change`/`drop` handler either way, but it only uploads +
|
|
130
|
+
separates once activation is present. `--js` instead dispatches a synthetic
|
|
131
|
+
(isTrusted=false) `DataTransfer` drop **without** force-fronting/stealing focus,
|
|
132
|
+
for zones that accept synthetic events. The `<ref>` can be any snapshot element
|
|
133
|
+
sitting over the drop region (a heading/button inside the zone) — the drop
|
|
134
|
+
bubbles to the zone/document handler, so it works even when the drop div itself
|
|
135
|
+
isn't snapshot-interactive. After the drop, `read`/`screenshot`/`network` to
|
|
136
|
+
confirm processing started, then grab the result (often a download endpoint you
|
|
137
|
+
can pull with `download --url`).
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Renderer health — slow tabs, wedged Chrome, tabs that never paint
|
|
2
|
+
|
|
3
|
+
Reference for the `browser` skill. Read it when `new`/`goto` time out or are suddenly slow,
|
|
4
|
+
`eval` times out, a site seems to "block" you, `doctor` reports a renderer problem, a page
|
|
5
|
+
reads as a frozen shell, or before you even consider `launch --restart`. The hard rules are
|
|
6
|
+
in `SKILL.md`, under Gotchas; this is the evidence, the diagnosis and the recovery order.
|
|
7
|
+
|
|
8
|
+
- **A NEW tab's renderer can be slow rather than broken — do not restart Chrome for it.**
|
|
9
|
+
⚠️ **Read this before acting on the wedge diagnosis in the next item.** Measured 2026-09-11 on
|
|
10
|
+
Chrome 152.0.7977.83, time from `Target.createTarget` to the first `Runtime.evaluate`
|
|
11
|
+
returning, 8 trials each:
|
|
12
|
+
|
|
13
|
+
| how the target was created | median | worst |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `background: true` (how this tool opens every tab) | 367ms | 12517ms, and >30s once |
|
|
16
|
+
| `background: true` + `Target.activateTarget` | 19ms | 65ms |
|
|
17
|
+
| `background: false` | 18ms | 22ms |
|
|
18
|
+
|
|
19
|
+
The renderer **process exists** in every arm — `ps` gains a `--type=renderer` child either
|
|
20
|
+
way. A background target is simply not given a renderer that answers promptly, and on a
|
|
21
|
+
loaded machine (this one was at load average 38) the tail runs past any budget worth
|
|
22
|
+
waiting. **This is not the wedge**, and a restart does nothing for it.
|
|
23
|
+
|
|
24
|
+
It cost real work to learn: for three weeks `goto` reported this as the permanent,
|
|
25
|
+
restart-only condition below, and `launch --restart` closes every tab of every session
|
|
26
|
+
sharing this Chrome. It twice destroyed unrecoverable work belonging to another session —
|
|
27
|
+
a finished AlternativeTo submission with hand edits, and an Azure signup flow mid-form.
|
|
28
|
+
|
|
29
|
+
**Since fixed (v0.4.12+):** `new`/`goto` wait for a late renderer and, if it still has not
|
|
30
|
+
answered, briefly activate the tab to force one and hand the window straight back (you get
|
|
31
|
+
a `WARN` saying so). The probe retries with a doubling budget, and the verdict now names
|
|
32
|
+
the permanent failure **only when its own signature is present**. On an older CLI, the
|
|
33
|
+
cheap move is to retry, or to drive a tab that already works.
|
|
34
|
+
|
|
35
|
+
**Whatever the version: before restarting anything, check the two corroborations.** Both
|
|
36
|
+
were decisive and neither used to be consulted:
|
|
37
|
+
```bash
|
|
38
|
+
launchctl print "gui/$(id -u)" | grep MachPortRendezvousServer.<browser-pid>
|
|
39
|
+
ps -Ao command= | grep -c -- '--type=renderer'
|
|
40
|
+
```
|
|
41
|
+
Mach name **present** + renderers **alive** ⇒ this is slowness, not the wedge. Retry, or use
|
|
42
|
+
a live tab. Mach name **absent** ⇒ it is the wedge, and only then is a restart the answer.
|
|
43
|
+
|
|
44
|
+
- **"The site is blocking us" — when it is really Chrome that cannot make renderers.**
|
|
45
|
+
A browser process can permanently lose the ability to launch **renderer processes** while
|
|
46
|
+
looking perfectly healthy. Every tab that already exists keeps working, so nothing seems wrong
|
|
47
|
+
until you open a tab or navigate somewhere new, and then the errors read as the remote site's
|
|
48
|
+
doing. Diagnosed 2026-08-22; it cost an hour of blaming ferry-operator bot protection.
|
|
49
|
+
⚠️ **This is a real condition and a rare one.** Confirm the Mach name is absent (above)
|
|
50
|
+
before you believe it — a slow background renderer produces every symptom in this list.
|
|
51
|
+
|
|
52
|
+
How it shows up:
|
|
53
|
+
- `browser-automation new` + `goto` → `CDP Page.enable timed out after 30000ms`, **even for
|
|
54
|
+
`example.com`**.
|
|
55
|
+
- **Cross-origin** navigation of an existing, working tab → `navigate failed: net::ERR_ABORTED`.
|
|
56
|
+
Site isolation puts a new origin in a new renderer — the exact thing Chrome can no longer do.
|
|
57
|
+
- **Same-origin** navigation on that same tab keeps working perfectly (Skyscanner → Skyscanner
|
|
58
|
+
with new query params was fine throughout). That asymmetry is what makes it masquerade as
|
|
59
|
+
"only site X blocks us": the tab you were already using still behaves.
|
|
60
|
+
- A target created at the browser level (`PUT /json/new?<url>`) appears in `/json/list` with the
|
|
61
|
+
right URL but an **empty title forever**; every `Runtime.evaluate` against it times out.
|
|
62
|
+
`Page.captureScreenshot` returns `Internal error`. The target shell exists; the renderer does not.
|
|
63
|
+
|
|
64
|
+
**It gets SLOW before it fails outright — that is the early warning.** Observed 2026-09-07 on a
|
|
65
|
+
Chrome that had been up 12 days: every `goto` took ~25–30s, and a batch of three blew a 120s
|
|
66
|
+
timeout, hours before anything failed hard. That was misread as "large files, slow browser" and
|
|
67
|
+
worked around with longer timeouts for many minutes; the actual fix was one `launch --restart`,
|
|
68
|
+
after which the same pages loaded instantly and 14 `file://` tabs opened in two quick batches.
|
|
69
|
+
**A `goto` that has quietly become slow is this, not your page.** Raise the timeout at most once,
|
|
70
|
+
then run `doctor`.
|
|
71
|
+
|
|
72
|
+
**Every cheap signal stays green, so do not take any of them as health.** On that same wedged
|
|
73
|
+
browser: `launch` said `Already running on :9223 — nothing to do.`, `curl :9223/json/version`
|
|
74
|
+
answered normally, and `list` cheerfully returned 10 targets — while `goto` exited 1 and `eval`
|
|
75
|
+
died with `CDP Runtime.evaluate timed out after 30000ms`. Port held, HTTP endpoint answering and
|
|
76
|
+
targets listed are all properties of the **browser** process; the thing that is broken is its
|
|
77
|
+
ability to start a **renderer**, and only a probe that runs code in one can see it.
|
|
78
|
+
**Since fixed:** `launch` now runs that probe itself and exits non-zero with the diagnosis
|
|
79
|
+
instead of reporting "nothing to do", so this particular green-across-the-board trap is closed.
|
|
80
|
+
It still will not restart for you — that stays something you type, because the tabs are not
|
|
81
|
+
only yours. On a CLI old enough to lack it, `doctor` is the same probe; nothing cheaper
|
|
82
|
+
substitutes for either.
|
|
83
|
+
|
|
84
|
+
**The mechanism** (macOS, from Chrome's own log at `$TMPDIR/chrome-<port>.log` — `launch --restart`
|
|
85
|
+
keeps the previous browser's log as `chrome-<port>.log.prev`, which is the one you want after a
|
|
86
|
+
restart):
|
|
87
|
+
```
|
|
88
|
+
ERROR:base/apple/mach_port_rendezvous_mac.cc:256]
|
|
89
|
+
bootstrap_look_up com.google.Chrome.MachPortRendezvousServer.<pid>: (ipc/send) invalid destination port
|
|
90
|
+
ERROR:base/memory/shared_memory_switch.cc:261]
|
|
91
|
+
No rendezvous client, terminating process (parent died?)
|
|
92
|
+
```
|
|
93
|
+
A Chrome child process gets its shared-memory handles by looking up a Mach bootstrap service the
|
|
94
|
+
browser registers **once, at startup**, named `com.google.Chrome.MachPortRendezvousServer.<browser-pid>`.
|
|
95
|
+
That registration had vanished from the user's launchd namespace — confirmed absent via
|
|
96
|
+
`launchctl print gui/$UID | grep MachPortRendezvousServer.<pid>`, while two healthy Chromes on the
|
|
97
|
+
same machine were both listed. From then on **every renderer Chrome launches kills itself within
|
|
98
|
+
milliseconds**, which is why none ever appears in `ps` and why the browser only reports
|
|
99
|
+
`Render process gone.` **What made the name vanish is not established.** Two things
|
|
100
|
+
correlated and neither is proven: the binary on disk had moved to 151.0.7922.170 while the live
|
|
101
|
+
browser was still running .138, and `GoogleUpdater` was FATAL-ing on its own `bootstrap_check_in`
|
|
102
|
+
with error 141. But the first renderer failure (18:53) *preceded* the first updater FATAL (19:42)
|
|
103
|
+
by ~50 minutes, so the update churn is at best a fellow symptom of a sick launchd bootstrap
|
|
104
|
+
namespace, not the cause. Treat the trigger as unknown; the diagnosis and the recovery do not
|
|
105
|
+
depend on it.
|
|
106
|
+
|
|
107
|
+
**It is NOT about how many tabs are open.** That was the first theory and it is wrong: a freshly
|
|
108
|
+
launched Chrome on the same machine was driven to **421 page targets / 435 live renderer
|
|
109
|
+
processes, every one responsive**, and a 256-fd `ulimit` made no difference either (205 renderers,
|
|
110
|
+
all fine). The broken browser had 66 tabs. The count was a coincidence — so do not treat a big
|
|
111
|
+
tab count as evidence of this, and do not expect closing tabs to fix it.
|
|
112
|
+
|
|
113
|
+
**Diagnose it:**
|
|
114
|
+
```bash
|
|
115
|
+
browser-automation doctor # measures renderer capacity, not just reachability
|
|
116
|
+
```
|
|
117
|
+
`doctor` now creates a throwaway tab, makes its renderer evaluate `1+1`, and closes it — the one
|
|
118
|
+
round-trip that separates a wedged browser from a slow network or a hostile site. On failure it
|
|
119
|
+
names the root cause (including the missing bootstrap service and the pid) and points at Chrome's
|
|
120
|
+
log. On a healthy browser it reports e.g. `✓ Renderer capacity: a new tab got a live renderer in
|
|
121
|
+
73ms`. `goto` and `new` run the same probe automatically **on the error path only**, so a bare
|
|
122
|
+
`Page.enable timed out` now arrives with the diagnosis attached instead of sending you to the
|
|
123
|
+
site's bot-protection docs.
|
|
124
|
+
|
|
125
|
+
**Recovery — cheapest first, and a restart only once the Mach name is confirmed absent.**
|
|
126
|
+
|
|
127
|
+
1. **Retry.** A new tab's renderer has been measured taking 12s and more on a loaded
|
|
128
|
+
machine, and late is not broken.
|
|
129
|
+
2. **Drive a tab that already works.** An existing tab navigates same-origin without
|
|
130
|
+
needing a new renderer, so it keeps working throughout even during a genuine wedge:
|
|
131
|
+
```bash
|
|
132
|
+
browser-automation list
|
|
133
|
+
browser-automation eval -t <id> "location.href='<url>'"
|
|
134
|
+
```
|
|
135
|
+
3. **`browser-automation doctor`** — re-measures, prints the two corroborations, and shows
|
|
136
|
+
the recent probe-time distribution from `~/.browser-automation/renderer-probes.jsonl`.
|
|
137
|
+
4. **Only if `doctor` reports the Mach rendezvous service ABSENT**, restart. The bootstrap
|
|
138
|
+
name is registered at startup and never re-registered, so nothing short of a new browser
|
|
139
|
+
process helps; closing tabs does not, and plain `launch` will not either (idempotent by
|
|
140
|
+
design — it sees a live browser and exits happy):
|
|
141
|
+
```bash
|
|
142
|
+
browser-automation launch --restart # quit (CDP, then SIGTERM), wait for the profile, relaunch
|
|
143
|
+
```
|
|
144
|
+
It reports how many tabs it is about to close. `Chrome released its profile but left its
|
|
145
|
+
process running (normal on macOS); ending it.` is the **expected** line, not a fault: on
|
|
146
|
+
macOS 27 / Chrome 153 the browser process never exits on its own after quitting, but it
|
|
147
|
+
does flush and release the profile first, and that release is what the restart waits for.
|
|
148
|
+
(Older CLIs waited only for the port to close and relaunched on top of the still-running
|
|
149
|
+
Chrome — two browsers on one profile. If you see `Chrome did not exit on SIGTERM`, or no
|
|
150
|
+
such line and then odd profile errors, you are on one of those.) **Those tabs belong to every parallel
|
|
151
|
+
Claude Code session sharing this Chrome — ask Fred first, never restart unilaterally.**
|
|
152
|
+
|
|
153
|
+
**Housekeeping is a different problem** — `browser-automation gc` prunes stale session bookmarks
|
|
154
|
+
(they are never cleaned up otherwise; this machine had accumulated 234, only 5 of them live) and
|
|
155
|
+
closes tabs whose renderer does not answer. Use `--dry` first. `list` now counts stale
|
|
156
|
+
bookmarks instead of printing them (`list --all` to see them) — 105 stale lines above a
|
|
157
|
+
24-tab Chrome is how "there are a hundred tabs open" became the leading theory for a
|
|
158
|
+
renderer failure that has nothing to do with tab count. It is genuinely useful, but it is
|
|
159
|
+
**not** a fix for the wedge above, and it never closes a working tab unless you pass `--orphans`
|
|
160
|
+
— tabs get addressed by `-m` and opened by hand, so "no session claims it" is not evidence that
|
|
161
|
+
nobody wants it.
|
|
162
|
+
|
|
163
|
+
**The false lead to resist:** a bare `curl` to a suspicious site may genuinely return a bot wall
|
|
164
|
+
(vikingline.fi serves an Imperva "Pardon Our Interruption" page, HTTP 200), which feels like
|
|
165
|
+
confirmation. It confirms nothing about the browser path — the persistent, cookie-bearing profile
|
|
166
|
+
is a completely different client. Check the browser first: if `doctor` says renderer capacity is
|
|
167
|
+
fine and a boring cross-origin URL loads, *then* start suspecting the site.
|
|
168
|
+
|
|
169
|
+
- **A backgrounded tab may never paint at all — and `read`/`snapshot` will not tell you.** Distinct
|
|
170
|
+
from "still loading": `document.readyState` reaches `complete`, but the SPA never renders, so
|
|
171
|
+
`read` returns a stale shell (e.g. a bare "Loading") and `snapshot` lists none of the real
|
|
172
|
+
controls. The trap is that this looks exactly like *the page does not have that element*, and you
|
|
173
|
+
will go hunting for a different selector or conclude the flow changed. Measured 2026-09-02 on
|
|
174
|
+
Google's `accounts.google.com/v3/signin/challenge/pwd`: `readyState: "complete"`,
|
|
175
|
+
`body.innerText.length: 202` frozen on the previous step's text, and the password field present in
|
|
176
|
+
the DOM but `offsetParent === null` for as long as the tab stayed backgrounded.
|
|
177
|
+
**Diagnose** before changing your selector:
|
|
178
|
+
```bash
|
|
179
|
+
browser-automation eval -s x '({ready:document.readyState,vis:document.visibilityState,len:document.body.innerText.length})'
|
|
180
|
+
```
|
|
181
|
+
`visibilityState: "hidden"` with a **stuck `len`** is this, not a selector problem. Note the
|
|
182
|
+
stuck `len` is the whole tell: `hidden` on its own is the normal, healthy state of every
|
|
183
|
+
backgrounded tab — verified 2026-09-07, a background tab reporting `hidden` returned its real
|
|
184
|
+
painted text — so never read `hidden` alone as a diagnosis.
|
|
185
|
+
**Fix:** make the tab report itself visible.
|
|
186
|
+
```bash
|
|
187
|
+
browser-automation focus -s x # quiet: no window moves, you keep your frontmost app
|
|
188
|
+
```
|
|
189
|
+
`focus` emulates focus + visibility in the renderer, then **reads back what it actually
|
|
190
|
+
achieved** rather than reporting that it sent the command — so a partial result says which half
|
|
191
|
+
is missing instead of printing a tick over it. The page paints immediately. Add `--raise` only
|
|
192
|
+
when a *person* needs to see the tab: that genuinely fronts it and **takes the operator's
|
|
193
|
+
screen**, which is exactly what you normally want to avoid.
|
|
194
|
+
Same root cause as the WebAuthn note in [`input-and-forms.md`](input-and-forms.md), different symptom: that one refuses, this one
|
|
195
|
+
silently never renders.
|
|
196
|
+
*(Older CLIs had no `focus`; the workaround was a `click --trusted` on a harmless wrapper `div`,
|
|
197
|
+
which fronted the tab as a side effect of needing trusted input. Prefer `focus` — it says what it
|
|
198
|
+
achieved, and it does not click anything.)*
|
|
199
|
+
|
|
200
|
+
**Do not confuse this with the renderer wedge (previous item).** Both present to an operator as "the page
|
|
201
|
+
isn't there, but every tool says fine", and the fixes are opposite — one is a per-tab nudge, the
|
|
202
|
+
other closes every tab in the browser. What separates them:
|
|
203
|
+
|
|
204
|
+
| | backgrounded tab never paints | Chrome cannot make renderers |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| `goto` | succeeds, rc=0 (may be slow) | **rc=1**, or `Page.enable timed out` |
|
|
207
|
+
| `eval` | works, returns a result | **`Runtime.evaluate` times out at 30000ms** |
|
|
208
|
+
| scope | that one tab | **every** new tab / cross-origin nav |
|
|
209
|
+
| `doctor` | `✓ Renderer capacity` | names the wedge + pid |
|
|
210
|
+
| fix | `focus` on the tab | `launch --restart` (**ask first**) |
|
|
211
|
+
|
|
212
|
+
`eval` is the fast discriminator: if it answers at all, the renderer is alive and you are in the
|
|
213
|
+
painting case. If it times out, stop poking the page and run `doctor`.
|