Repository navigation
fix(serve): cap and reclaim offscreen browser tabs (port of upstream #19628) - #369
Merged
Merged
Conversation
…tream #19628) Port de stablyai/orca#19628. Cada tab offscreen es un BrowserWindow con su propio proceso renderer, y en un `orca serve` headless nada reclama el que un agente se olvido de cerrar — tampoco hay ventana donde se vea crecer. Upstream midio un dia de trabajo llegando a 9 tabs con 6 renderers de 220-480 MB en un host de 4 vCPU / 8 GB: load 6.85, 2.5 GB de swap, y un cliente que solo decia "Reconnecting to remote runtime". Nos aplica directo: contabo corre dos instancias en 11 GiB. Los dos modulos nuevos entran tal cual. El backend se adapta porque el nuestro es anterior al de upstream: - Nuestro constructor no tenia options bag; se agrega uno con `maxTabs` y `rendererProcessControl` solamente. El `getAgentBrowserBridge` de upstream no existe aca. - No tenemos `retirePageOwner`, asi que la parte de `settleOwnerRetirement` no aplica; queda el reclamo del renderer, que es lo que libera el puesto. - No tenemos taxonomia de errores de browser. En vez de inventarla para cargar un codigo, la refusal declara su propia clase con el MISMO codigo que usa upstream (`browser_tab_capacity`), asi un caller que ya lo maneja sigue andando. Queda fuera un caso de test de upstream: "does not spend a slot on a page the registry refused" afirma un camino que aca no existe — nuestro `registerOffscreenGuest` devuelve `void` y no puede rechazar. Hacerlo rechazable es cambiar el contrato de browser-manager, que es otra cosa. 654 tests de browser en verde.
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.
Port of
stablyai/orca#19628. Second slice of the upstream batch — #368 carries the six that applied cleanly; this one needed real adaptation, so it ships on its own rather than risking that batch.Why it matters here
Every offscreen browser tab is a
BrowserWindowwith its own renderer process, and on a headlessorca servenothing reclaims one an agent forgot to close — there is no window in which the growth is visible either. Upstream measured a single working day reaching 9 open tabs backed by 6 renderers of 220-480 MB each on a 4 vCPU / 8 GB host: load average 6.85, 2.5 GB of swap in use, and a paired client that reported only "Reconnecting to remote runtime".That is our deployment:
orca-contaboruns two instances on 11 GiB.What entered as-is
offscreen-browser-tab-capacity.tsandoffscreen-renderer-process-reclaim.tsare self-contained and taken verbatim, including the reasoning for the default of 4 and theORCA_MAX_OFFSCREEN_BROWSER_TABSoverride (1-64).What was adapted, and why
Our
offscreen-browser-backend.tspredates upstream's:constructor(private readonly browserManager: BrowserManager) {}. Added one carrying onlymaxTabsandrendererProcessControl; upstream'sgetAgentBrowserBridgedoes not exist here.retirePageOwner. SosettleOwnerRetirementand its 5 s timeout have nothing to wrap. The renderer reclaim — the half that actually frees the slot — is kept.browser_tab_capacity), so a caller that already handles that keeps working.One upstream test left out
does not spend a slot on a page the registry refusedasserts a path that does not exist here: ourregisterOffscreenGuestreturnsvoidand cannot refuse, while upstream's returns a boolean. Making it refusable changesbrowser-manager's contract, which is a different change from the cap — so it is named here rather than quietly adapted.Tests
7 of upstream's 8 cases, plus the whole browser suite: 654 tests green.
check:test-case-deletionOK (none lost), max-lines ratchet OK.