mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-28 04:24:51 +02:00
[eric] perf: mass-delete parallel-detaches browsers too (removeBrowserCardsCleanly); flat latency, same crash-safe ordering
This commit is contained in:
@@ -38,3 +38,17 @@ export async function removeBrowserCardCleanly(
|
||||
forgetBrowser(browserId);
|
||||
dispatch(removeBrowserCard(browserId));
|
||||
}
|
||||
|
||||
// Batch remove: detach every browser's CDP in PARALLEL (order-independent, the only invariant is
|
||||
// all debuggers gone before any unmount), THEN remove them. Serial detach cost ~72ms/browser, so a
|
||||
// 20-card multi-select delete lagged over a second; this keeps the crash-safe ordering but flat.
|
||||
export async function removeBrowserCardsCleanly(
|
||||
browserIds: string[],
|
||||
dispatch: Dispatch,
|
||||
): Promise<void> {
|
||||
await Promise.allSettled(browserIds.map((id) => detachBrowserCdp(id)));
|
||||
for (const id of browserIds) {
|
||||
forgetBrowser(id);
|
||||
dispatch(removeBrowserCard(id));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user