Skip to content

Prevent chat code execution when R console is busy - #16875

Merged
gtritchie merged 3 commits into
mainfrom
prevent-overlapping-execution
Jan 23, 2026
Merged

gtritchie merged 3 commits into
mainfrom
prevent-overlapping-execution

Conversation

@gtritchie

@gtritchie gtritchie commented Jan 23, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Queue chat runtime/executeCode requests to wait for R to be idle before executing, preventing overlapping output and potential crashes
  • Add execution queue limit (10 pending requests) to prevent unbounded growth when R is busy for extended periods
  • Add queue timeout (60 seconds) to prevent indefinite waiting
  • Properly release mutex before I/O operations for consistent locking patterns

Addresses the issue where sending chat code execution while R is already running code in the console causes both to execute simultaneously.

QA Notes

  1. Basic queuing test:

    • Run Sys.sleep(5) in console
    • Send chat code execution request
    • Verify it waits and executes after sleep completes
  2. Queue limit test:

    • Run Sys.sleep(30) in console
    • Send 11 chat requests rapidly
    • Verify 11th is rejected with "queue full" error
  3. Timeout test:

    • Run Sys.sleep(65) in console
    • Send chat request
    • Verify it times out after 60 seconds with appropriate error

Documentation

None

@posit-snyk-bot

posit-snyk-bot commented Jan 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gtritchie gtritchie added this to the Globemaster Allium milestone Jan 23, 2026
@gtritchie
gtritchie requested a review from kevinushey January 23, 2026 18:48
@kevinushey
kevinushey requested a review from Copilot January 23, 2026 19:39

@kevinushey kevinushey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents simultaneous execution of chat code and console code by implementing a queue-based execution system with safety limits. When the R console is busy, chat code execution requests are queued and processed only when R becomes idle.

Changes:

  • Implemented execution queue with configurable limits (10 pending requests max, 60-second timeout)
  • Modified execution scheduling to wait for R idle state using idleOnly=true parameter
  • Added proper mutex management with explicit unlocking before I/O operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

4 participants