Keep a Bot's browser closed until its reset has finished, so a reset always signs it out - #554
Merged
davidmckayv merged 2 commits intoSep 15, 2026
Conversation
zopeVaibhav
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 15, 2026 12:25
…always signs it out
zopeVaibhav
force-pushed
the
fix/reset-racing-action
branch
from
September 15, 2026 16:27
5b3d8bc to
b1789ea
Compare
# Conflicts: # CHANGELOG.md
davidmckayv
approved these changes
Sep 15, 2026
davidmckayv
left a comment
Contributor
There was a problem hiding this comment.
Code-verified clean; CI green on this sha.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #553
What this changes
A reset closes a Bot's browser and then deletes its profile, and for the two seconds the close takes, the browser was already out of
live. A Bot action in that window launched a new browser from the profile about to be deleted and kept its logins.createProfilesnow tracks closes in flight in aclosingmap.evictholds an entry for the whole close,resetholds one across the close and the delete, andpage()waits for that entry before it looks for a live browser or a launch. The action is answered a couple of seconds later, on an empty profile.page()waits only when an entry exists. An unconditional await put a tick between the call and the launch registering instarting, and the two existing tests for a stop or a reset landing mid-launch failed on it.The same wait covers a close from the cap, the idle sweep and a stop, which could previously start a second Chromium on a profile whose first one was still exiting. A request for that Bot now waits up to about two seconds instead.
Left alone: the supervisor's reset, which removes the container and was not affected.
Where it runs
liveandstartingand is per process for the same reason they are: the browsers and their profile directories belong to this process.Boundary and audit
No change to the gateway or the rows it writes. The
computer.resetrow is now true when a Bot acts during a reset.Changelog
A line under
Unreleased.Proof
agent-computer/tests/browser-close-announcement.test.ts: it sets a persistent cookie, reopens the browser to confirm the cookie is on disk, starts a reset, asks for the page 100ms later and reads its cookies at once, then checks them after the reset. Run in the agent-computer image withOPENBOT_LIVE_SCREEN=1, it fails againstmain(a96d88c), receiving the cookie, and passes on this branch. A first version that read cookies only after the reset passed onmain, because Chromium loads cookies on first use; reading them at once is what an action does.main, 317 pass and 4 fail on this branch. The four failures are the same tests on both sides, so none comes from this change.main's code and one on this branch, each with a Bot signed in to a local page and a reset raced by a navigate. Onmain, navigates at 1.0s and 1.8s left the Bot SIGNED-IN. On this branch each navigate was answered after about 2.2s and the Bot ended SIGNED-OUT, and a control reset signed out.tsc --noEmitinagent-computer: clean. Biome reports nothing new; its import-order note onprofiles.ts:36is onmaintoo, and this change does not touch the imports.main's code and then on this branch, while Bot actions went through the server every 250ms for 12 seconds. Onmainall 48 actions and a check afterwards were SIGNED-IN, and the audit trail recordedcomputer.resetwith "the computer and its saved state were deleted". On this branch, the eight actions sent while the browser was closing waited about two seconds for the reset, every later action was SIGNED-OUT, and so was the check afterwards. Those eight came backnet::ERR_ABORTED, because they were released together and navigated one page at once; nine simultaneous navigations with no reset give the same errors.ci/gke-values.yaml: the API server at 2 replicas, all pointed at one shared computer StatefulSet withreplicas: 1. Not installed on a cluster.