Description
Summary
Running multiple opencli commands concurrently for the same site can fail with:
Detached while handling command.
This appears to be caused by browser workspace reuse across commands for the same site.
Environment
- opencli version: 1.7.5
- Node.js version: v24.14.0
- OS: Ubuntu 22.04.1 LTS (Jammy Jellyfish) on WSL2
- Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
- Browser Bridge extension installed: yes
- Extension version: 1.0.0
- Extension compatibility range reported by daemon: >=1.7.0
Root Cause Analysis
From local investigation, this seems to happen because:
-
execution.js creates browser sessions with a shared workspace key based only on site:
workspace: site:${cmd.site}
-
Command execution later closes the automation window:
await page.closeWindow?.()
-
When two commands for the same site run concurrently, they appear to share the same workspace/window.
If one command finishes first and closes the window, the other command may still be in goto() or evaluate(), and then fails with:
Detached while handling command
Relevant code path from local inspection:
- dist/src/execution.js
- browser session uses workspace: site:${cmd.site}
- command completion calls page.closeWindow?.()
Suggested Fix
Use a unique workspace per command execution instead of sharing by site for one-shot adapter commands.
For example, instead of:
workspace: site:${cmd.site}
something like:
workspace: site:${cmd.site}:cmd:${process.pid}:${Date.now()}
or another per-execution unique identifier.
This would prevent concurrent commands from closing each other's automation window.
Notes
This is particularly important for AI-agent scenarios, where parallel tool execution is common and expected.
Steps to Reproduce
- Ensure the Browser Bridge extension is connected and
opencli browser-backed commands work normally.
- Run two commands concurrently for the same site, for example:
OPENCLI_DIAGNOSTIC=1 opencli alm story ST645503 --tasks --format json &
OPENCLI_DIAGNOSTIC=1 opencli alm story ST645503 --tasks --format json &
wait
- Observe that one command may succeed while the other fails.
- The failing command reports an error similar to:
Expected Behavior
Concurrent commands for the same site should not interfere with each other. Both commands should complete successfully.
OpenCLI Version
1.7.5
Node.js Version
22.x
Operating System
Linux
Logs / Screenshots
Description
Summary
Running multiple
openclicommands concurrently for the samesitecan fail with:This appears to be caused by browser workspace reuse across commands for the same site.
Environment
Root Cause Analysis
From local investigation, this seems to happen because:
execution.js creates browser sessions with a shared workspace key based only on site:
workspace:
site:${cmd.site}Command execution later closes the automation window:
await page.closeWindow?.()
When two commands for the same site run concurrently, they appear to share the same workspace/window.
If one command finishes first and closes the window, the other command may still be in goto() or evaluate(), and then fails with:
Detached while handling command
Relevant code path from local inspection:
Suggested Fix
Use a unique workspace per command execution instead of sharing by site for one-shot adapter commands.
For example, instead of:
workspace:
site:${cmd.site}something like:
workspace:
site:${cmd.site}:cmd:${process.pid}:${Date.now()}or another per-execution unique identifier.
This would prevent concurrent commands from closing each other's automation window.
Notes
This is particularly important for AI-agent scenarios, where parallel tool execution is common and expected.
Steps to Reproduce
openclibrowser-backed commands work normally.Expected Behavior
Concurrent commands for the same site should not interfere with each other. Both commands should complete successfully.
OpenCLI Version
1.7.5
Node.js Version
22.x
Operating System
Linux
Logs / Screenshots