Repository navigation
Conversation
Drop the scheduled sweep from BrowserSessions. Browser Run already deletes a browser once keep_alive elapses without activity, and resolve() already detects that loss and replaces the browser with restarted: true, so the sweep only duplicated platform behavior while waking otherwise idle objects. - BrowserSessions schedules nothing: no sweep job, no onStart/onJob/ onJobError hooks, no sweepIdleMs, no manual sweep(). - close() and dead-session recovery move the record to its browser:retired: marker under the name's lock instead of leaving a tombstone, so listing named sessions yields only live records. - sessions() reports "live" or "expired" from updatedAt versus keep_alive; closed names are no longer listed. - NamedBrowserSessions drops sweep(), tombstone pruning, and the in-memory activity map; activity touches stay, capped at half the keep-alive window, so status stays accurate.
|
⚪ agents import sizesMeasured 344 runtime imports as minified bundles. The primary size is gzip; raw minified size is included for diagnosis. An existing import growing by more than 10% is marked red. This report is informational.
Compared No import sizes changed. All 344 current runtime imports
Reported by agent-think[bot]. |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
A resolve that found the name unused checked for the retired marker before its Browser Run create, then committed whenever the key was empty. If another resolver created and closed the name during that create, the commit returned restarted: false even though the name had already lost a browser. Retired markers are permanent, so reading the marker under the commit lock always sees such a close.
fdaaa00
into
feat/browser-lifecycle-capability
* feat(agents): add the browser-sessions Lifecycle capability BrowserSessions (capability id "browser") packages the named-session core for Lifecycle hosts — Agent subclasses and plain Durable Objects alike: - auto-supplies a DurableBrowserSessionStore over the host's own storage (custom stores still pluggable; list-less stores sweep manually) - schedules the idle sweep through the Lifecycle job queue, armed only while sessions or tombstones exist, with onStart crash recovery - host-only observability: sessions() views and liveView() links minted fresh per call from a live target listing, never persisted Live View vocabulary (mode, URL shapes, TTL, minting) moves to browser/live-view.ts; connector.ts re-exports it unchanged. The shared isMissingBrowserSession judgment moves into browser-run.ts. * refactor(agents): let Browser Run keep_alive reclaim idle named sessions (#2358) * refactor(agents): let Browser Run keep_alive reclaim idle named sessions Drop the scheduled sweep from BrowserSessions. Browser Run already deletes a browser once keep_alive elapses without activity, and resolve() already detects that loss and replaces the browser with restarted: true, so the sweep only duplicated platform behavior while waking otherwise idle objects. - BrowserSessions schedules nothing: no sweep job, no onStart/onJob/ onJobError hooks, no sweepIdleMs, no manual sweep(). - close() and dead-session recovery move the record to its browser:retired: marker under the name's lock instead of leaving a tombstone, so listing named sessions yields only live records. - sessions() reports "live" or "expired" from updatedAt versus keep_alive; closed names are no longer listed. - NamedBrowserSessions drops sweep(), tombstone pruning, and the in-memory activity map; activity touches stay, capped at half the keep-alive window, so status stays accurate. * refactor(agents): expose named sessions through a lazy private getter * fix(agents): read restart evidence when a named session commits A resolve that found the name unused checked for the retired marker before its Browser Run create, then committed whenever the key was empty. If another resolver created and closed the name during that create, the commit returned restarted: false even though the name had already lost a browser. Retired markers are permanent, so reading the marker under the commit lock always sees such a close. * refactor(agents): rename mintLiveView to createLiveView
Stacked on #2293. Follows up Aron's review of the sweep.
Why
I spent a bit more time thinking about how we were doing this and realised that we didn't really need this sweep functionality because we'd basically be duplicating the session management already built into the Browser Run platform. Browser Run already reclaims idle browsers: once
keep_alive(600s) passes with no activity, the platform deletes the browser. The nextresolve()notices it's gone and replaces it withrestarted: true. Our scheduled sweep was doing the same job a second time from the host side.flowchart LR subgraph Before A1[Idle browser] --> S[Host sweep<br/>alarm + job + rearm<br/>+ activity tracking] A1 --> K1[Browser Run keep_alive] S --> D1[Deleted] K1 --> D1 end subgraph After A2[Idle browser] --> K2[Browser Run keep_alive] K2 --> D2[Deleted] end D1 & D2 --> R["next resolve() → fresh browser, restarted: true"]Dropping the sweep:
Models see no difference:
restartedis set in the same cases as before. Neither class is exported yet, so no changeset.Also turns
#core_()into a lazy#namedSessionsgetter to address another of the comments on that PR.