Skip to content

fix: use unique workspace per command execution (fixes #1114)#1117

Merged
jackwener merged 1 commit intojackwener:mainfrom
kagura-agent:fix/concurrent-workspace-1114
May 3, 2026
Merged

fix: use unique workspace per command execution (fixes #1114)#1117
jackwener merged 1 commit intojackwener:mainfrom
kagura-agent:fix/concurrent-workspace-1114

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

Summary

Fix concurrent commands for the same site failing with Detached while handling command.

Closes #1114

Root Cause

Browser command execution uses a workspace key based only on site name (site:${cmd.site}). When two commands for the same site run concurrently, they share the same browser session. If one finishes first and calls page.closeWindow(), the other command's page is detached mid-execution.

Fix

Append crypto.randomUUID() to the workspace key so each command gets its own isolated browser session:

// Before
workspace: \`site:\${cmd.site}\`

// After  
workspace: \`site:\${cmd.site}:\${crypto.randomUUID()}\`

Testing

  • All 1767 existing tests pass
  • npx tsc --noEmit clean
  • Surgical 1-line change in src/execution.ts

@Henry-G-H-Huang
Copy link
Copy Markdown

any update about this PR ?

@kagura-agent
Copy link
Copy Markdown
Contributor Author

Hi @Henry-G-H-Huang — thanks for the ping! The PR is still up to date and mergeable. Waiting on maintainer review. Let me know if there's anything I can help with!

@kagura-agent
Copy link
Copy Markdown
Contributor Author

@jackwener Friendly ping — the issue reporter has asked about this a few times now. The PR is clean and ready to merge whenever you have a moment. Thanks! 🙏

… conflicts (jackwener#1114)

Commands for the same site shared a workspace key based only on site name,
causing concurrent commands to interfere — one command closing the automation
window would detach the other mid-execution.

Append a random UUID to the workspace key so each command gets its own
browser session, preventing the 'Detached while handling command' error.
@kagura-agent kagura-agent force-pushed the fix/concurrent-workspace-1114 branch from a9edda7 to 268402d Compare May 1, 2026 19:07
@kagura-agent
Copy link
Copy Markdown
Contributor Author

@jackwener Third ping — the issue reporter has asked about this multiple times. The fix is mergeable and ready. If this doesn't align with your plans, I'm happy to close it. Just let me know. 🙏

@jackwener jackwener merged commit 98062a2 into jackwener:main May 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Concurrent commands for the same site can fail with "Detached while handling command"

3 participants