Bridge and OpenCode plugin: four limits that do not hold in v0.68.0 (pool size, reconnect fan-out, reload ceiling, status fan-out)
Description
A source review of v0.68.0 found four limits in the bridge and the OpenCode plugin that do not hold as their names say. We did not see a failure from them on a running system. The V2 deletion route close is already in #1476, so it is not repeated here.
1. The standalone pool can go above its size limit
When the pool is full, pool.ts:261-263 calls this.evictLRU(). That function skips each bridge that has pending requests or background tasks (pool.ts:336-337). When all bridges are busy, it removes nothing, and the new bridge is still created and added (pool.ts:274-281). Also, a removed bridge leaves the map before shutdown() completes (pool.ts:345-346), so its child process is not counted while it stops.
Effect: more aft child processes can run than maxPoolSize.
Possible repair: if the limit is for live child processes, count the bridges that are stopping, and queue or refuse a new bridge when the pool cannot remove a bridge.
2. Each background subscription reconnects on its own timer
The pool shares the daemon connection. But each retained BgSubscription (subc-transport.ts:3559) runs its own reconnect loop with its own backoff (subc-transport.ts:906-917: await this.backoff(backoffAttempt++)) and opens its own background route.
Effect: after a daemon restart, a service with many retained sessions sends one reattach for each session, at about the same time.
Possible repair: share one cancellable delay across subscriptions, and stagger the reattach in small groups.
3. A route open after a reload wait can run past the 45 s ceiling
subc-transport.ts:2523 sets reloadWaitBudgetMs = Math.min(callDeadlineMs, ROUTE_OPEN_RELOAD_WAIT_CEILING_MS). The check before the sleep uses that budget (:2568). But the next open waits against remainingMs() from the call deadline (:2537-2543), not against the reload budget.
Effect: when the call deadline is longer than 45 s, an open that starts near the ceiling can continue past it. The call deadline still applies.
Possible repair: limit each open in the reload loop to the time that remains in the reload budget.
4. A session status change goes to every V2 Location
Each V2 Location registers its status sink without a sessionId (rpc/register.ts:355-361). The matcher treats sink.sessionId === undefined as a match (rpc-notifications.ts:60-61).
Effect: an invalidation for one session goes to the sinks of all Locations. With many Locations open in one service, each status change causes that many statusInvalidated events.
Possible repair: register the sink with the Location's sessions, or send the event only to the Location that owns the session.
Environment
- AFT v0.68.0, OpenCode 2 service with many Locations. Item 1 applies to standalone mode.
- Found by source review. This report has no reproduction.
Thanks, @iceteaSA. Status of the four against our next batch:
- Pool size: by design now. The pool is a soft limit: when every bridge is busy, AFT opens another one and logs it, rather than refusing the project, then trims back as bridges go idle. We'll make that clearer in the code docs.
- Reconnect fan-out: confirmed. Background subscriptions will share one backoff and reattach in small staggered groups.
- Reload ceiling: the reading is right, but we're keeping the behaviour. The 45 s ceiling limits how long AFT keeps waiting through repeated reload refusals. A retry that is already opening is limited by the call's own deadline. Cutting it at 45 s would turn a late success into a failure. We'll rename and comment the budget so the code says this, and pin it with a test.
- Status fan-out: confirmed. A session's status change will go only to the Location that owns the session.
We'll post here when a release carries them.