Skip to content

Commit 9671a9a

Browse files
committed
refactor(showcase/harness): migrate pooled launchers to context checkout
Update all five pooled probe launchers for the context-pooled BrowserPool. Each launcher's newContext() now checks out a pooled BrowserContext via pool.acquire(opts) and the returned context-wrapper's close() releases it via pool.release(ctx); the launcher-level close() is a no-op (no Browser is held). The X-AIMock-Strict literal is dropped from every launcher (now centralized in the pool); drivers still pass their per-probe X-AIMock-Context / X-Test-Id headers, which now flow through to pool.acquire. Driver run() bodies are unchanged. - d4 (createPooledE2eSmokeLauncher), e2e-parity (createPooledE2eParityLauncher): minimal transform. - e2e-readiness (createPooledE2eDemosLauncher), d5 (createPooledE2eDeepLauncher), d6 (createPooledE2eFullLauncher): the abort closure is re-targeted to close each open context (each releasing its pooled context) instead of force-releasing a held browser. d6's dead-browser re-acquire dance is removed, the pool only opens contexts on live browsers. Per-service Semaphore(FEATURE_CONCURRENCY/_D6) is preserved as the orthogonal per-service fan-out bound. Driver tests reinterpret POOL_SIZE as maxContexts and assert per-context acquire/release moves inUse by 1, abort closes open contexts with no browser fork, and newContext(opts).extraHTTPHeaders forwards into pool.acquire.
1 parent 88ead08 commit 9671a9a

8 files changed

Lines changed: 433 additions & 603 deletions

File tree

showcase/harness/src/probes/drivers/d4-chat-roundtrip.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,17 @@ export function createPooledE2eSmokeLauncher(
272272
pool: BrowserPool,
273273
): E2eBrowserLauncher {
274274
return async (): Promise<E2eBrowser> => {
275-
const browser = await pool.acquire();
275+
// CONTEXT-POOLED model: the launcher no longer acquires a Browser. Each
276+
// `newContext()` checks out a pooled BrowserContext on a shared long-lived
277+
// browser process (`pool.acquire`), and the wrapper's `close()` returns it
278+
// (`pool.release`). The pool centralizes the X-AIMock-Strict default header;
279+
// per-probe headers (X-AIMock-Context, X-Test-Id) flow through `ctxOpts`.
276280
return {
277281
async newContext(ctxOpts?: {
278282
extraHTTPHeaders?: Record<string, string>;
279283
}): Promise<E2eBrowserContext> {
280-
const ctx = await browser.newContext({
281-
extraHTTPHeaders: {
282-
"X-AIMock-Strict": "true",
283-
...ctxOpts?.extraHTTPHeaders,
284-
},
284+
const ctx = await pool.acquire({
285+
extraHTTPHeaders: ctxOpts?.extraHTTPHeaders,
285286
});
286287
return {
287288
async newPage(): Promise<E2ePage> {
@@ -296,12 +297,12 @@ export function createPooledE2eSmokeLauncher(
296297
close: () => page.close(),
297298
};
298299
},
299-
close: () => ctx.close(),
300+
close: () => pool.release(ctx),
300301
};
301302
},
302-
close: async () => {
303-
pool.release(browser);
304-
},
303+
// Launcher-level close is a no-op: contexts are released individually via
304+
// each context-wrapper's close(). There is no Browser held to release.
305+
close: async () => {},
305306
};
306307
};
307308
}

0 commit comments

Comments
 (0)