Skip to content

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

Open
kagura-agent wants to merge 1 commit intojackwener:mainfrom
kagura-agent:fix/concurrent-workspace-1114
Open

fix: use unique workspace per command execution (fixes #1114)#1117
kagura-agent wants to merge 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

… 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.
@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!

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"

2 participants