Repository navigation
fix(web): refuse commands on closed browser sessions - #4348
lucasacoutinho wants to merge 4 commits into
Conversation
|
Thanks for the fix. I read 61fcab1 and found one gap to close before merge, plus a design question. No checks report on this draft head yet. This changes web browser lifecycle through the daemon, and the PR has no live run for it. Please paste the transcript for: A close of an already-closed browser must be a no-op success. The guard at Could the refusal live at the daemon seam that already owns "session not held"? A non-open web request that names a session, resolves to a web device and finds no held session would answer Not blocking: |
A successful web close records the session on the daemon session store. Later non-open commands answer named_session_not_found before dispatch. Closing again succeeds and does not close the browser a second time. A session that was never opened still follows the device-selector path. Co-authored-by: Lucas Coutinho <mail@lucasacoutinho.com>
Session teardown asks the cleanup capability whether a browser closed and stores that answer. The capability stays the only place that selects web. Co-authored-by: Lucas Coutinho <mail@lucasacoutinho.com>
|
Head Auto-launch of a never-opened The refusal is Live Node 24, headless Chrome (agent-browser 0.39.0), private state dir. Snapshot after reopen is example.com’s “Learn more” link. Failed close: the backend Failed reopen: after a successful close,
|
|
Thanks for the update. I reviewed 4d89103 against the earlier findings (#4348 (comment)). The earlier issues are fixed, but one new problem remains in how the closed marker is cleared. The closed marker is keyed by the session address only, and it is cleared only for web opens (session-open-execution.ts#L303). The chain guard (request-handler-chain.ts#L146-L152) refuses every non-allowed command on a marked address, even when the daemon holds a session there. Sequence: Not blocking, and you can take or leave these: no test drives the No checks are reported on this head yet, and I could not verify the local check:affected run. There are no conflicts. Before merge, the marker must clear on any successful open and the regression test must be added. |
A non-web open of a marked address left the marker in place, so the next snapshot was refused as named_session_not_found. Every successful open now leaves the set, and the chain refuses a marked address only while no session is held there. Co-authored-by: Lucas Coutinho <mail@lucasacoutinho.com>
|
Thanks for the update. At d97c0db the earlier review items on the closed-session refusal are addressed in code, but three things remain, and the live validation is missing. The delta changes the pre-dispatch refusal predicate in request-handler-chain.ts: it adds the held-session condition and clears the marker on every platform. The live transcript and the check:affected receipt in the PR body are for 4d89103, so nothing shows the head still refuses on a real browser. Please rerun at d97c0db and update the Validation section. With --platform web --session S, run open about:blank, close, then snapshot. Snapshot must refuse with SESSION_NOT_FOUND, reason named_session_not_found, dispatched no. Then run open about:blank and snapshot, which must return the page tree. If an Android or iOS target is available, also run web open, close, then a non-web open on S and snapshot, and show it returns that device tree. Add the check:affected receipt for this head. The marker is cleared in session-open-execution.ts right after openApplication resolves, before the isRequestCanceled check, requireOpenSessionAdmission and the final publish. Does a canceled open, or one that loses admission, leave the marker cleared with no session published? If so, a later unheld named web command takes the never-opened auto-launch path. The marker should be cleared where the open publishes its session, after those checks. Likely also an issue: the new sessionStore.get(...) === undefined condition at request-handler-chain.ts:150 never changes the outcome on success routes, because every successful open clears the marker and an ordinary close retires the session. It matters when a session stays held after its browser was marked closed, since closePlatformObservingWebSession (session-close.ts:203-205) marks before retire. That can happen after a repair-armed close whose repair commit fails (prepareRepairClose), a failed provider lease release (runCloseTeardownAndRelease returns kind response), or closeAppWithoutEndingSession. At 4d89103 later commands on such a session were refused. At the head they dispatch to a closed browser, which is the original symptom in a failure branch. I did not confirm that a web session can be repair-armed or hold a provider lease in practice. The rule should be that a session cannot be both held and marked closed, so it needs a test for a web session kept after a failed close. Would it be simpler to set the marker inside SessionStore when a web session is retired after a successful platform close (for example, a retire option the close path passes), and clear it on every successful open publish? Then held-and-marked cannot exist, the chain guard reduces to hasClosedBrowserSession(address) && !allowed(command), and the held-session condition and its doc caveats go away. Not blocking, and fine to take or leave: the snapshot assertion in request-router-closed-web-session.test.ts is conditional and only checks the reason is not namedSessionNotFound, so it passes even if the unconditional clear is reverted. Asserting that the snapshot is dispatched (ok, or a device-level error) and dropping the conditional would test observable behavior. I traced the regression tests but did not run them. No checks report on this head (fork draft PR), so there is no failing job to attribute, and no conflicts are known. Before merge, the live rerun at d97c0db and the check:affected receipt for this head are needed. |
|
This branch now conflicts with main at d97c0db. Please rebase or merge main and resolve it. The open items from my last review (the live rerun at the new head, clearing the marker only where the open publishes its session, and a held session after a failed close) still apply after the rebase. |
Summary
Closing a web session records that browser on the daemon session store until the daemon restarts or an explicit open succeeds. Later non-open commands answer
SESSION_NOT_FOUNDwithnamed_session_not_foundanddispatched: no, including when--platform webis set. A second close succeeds and does not close the browser again. A session this daemon never opened still follows the device-selector path. A failed close stays retryable. A failed reopen stays closed.The process-record fleet no longer tracks closed sessions, and the provider does not refuse commands.
closed(session)is unchanged.Validation
Head
4d891037fe9f19e3bd2eb2b9f3f8a2b6715c45ed. Base093341a6040cc825763e05e0997bbeec7cdc085e.pnpm check:affected --run --head 4d891037fe9f19e3bd2eb2b9f3f8a2b6715c45edpassed withexactCommit: true(receiptrun-W3AMxE): format, lint, typecheck, layering, fallow, build, vitest-related, unit, docs-links, docs-prose. Web smoke and replay lanes are skipped here because GitHub owns them.Live Node 24 and headless Chrome, private state dir: open, close, then snapshot, screenshot, and click refuse before dispatch.
session listis empty. A second close succeeds. Open plus snapshot works again. A forced backend close failure left the session listed and a later snapshot worked. A forced open failure left the closed refusal in place. The private daemon was stopped.