fix(dsh-plugin-browserskill): enforce the session cap before spawning

The concurrency cap was checked in registry.add() AFTER
`bsk session start` had already created the session, so a rejected
start leaked a live session outside the plugin's tracking (found by the
real-browser e2e: the rejected third session stayed in
`bsk session list` after dispose). Check capacity before spawning;
registry.add() keeps the same check as a backstop.
This commit is contained in:
BB-fat
2026-08-13 15:27:29 +00:00
parent 703fc64399
commit 2de7c5c6ff
3 changed files with 17 additions and 5 deletions
@@ -160,6 +160,8 @@ export function registerTools(deps: ToolDeps): void {
if ((args.width === undefined) !== (args.height === undefined)) {
throw new Error("width and height must be given together");
}
// Check the cap BEFORE spawning so a rejected start never leaks a session.
registry.assertCapacity();
const startArgs = ["session", "start"];
if (args.width !== undefined && args.height !== undefined) {
startArgs.push("--width", String(args.width), "--height", String(args.height));