Skip to content

fix(js): bound async execute queue and validate input size before queueing#2062

Merged
chaliy merged 4 commits into
mainfrom
fix/pr-2042-js-async-queue
Jun 12, 2026
Merged

fix(js): bound async execute queue and validate input size before queueing#2062
chaliy merged 4 commits into
mainfrom
fix/pr-2042-js-async-queue

Conversation

@chaliy

@chaliy chaliy commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #2042

execute() calls that arrive while the shell is busy were queued without limit. Caps the per-instance backlog at 8 pending calls and rejects further calls with a clear error. Also validates maxInputBytes before the call enters the queue, and forwards maxInputBytes through toNativeOptions so the Rust core enforces the same limit.

Copilot AI review requested due to automatic review settings June 12, 2026 10:01
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 75677c7 Commit Preview URL

Branch Preview URL
Jun 12 2026, 10:38 AM

Copilot AI left a comment

Copy link
Copy Markdown

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 closes #2042 by adding bounded backpressure to async execute() calls and validating script size before commands are retained in async queues, reducing memory/DoS risk when callers enqueue faster than the shell can run.

Changes:

  • Add a per-instance async execute() queue with a hard cap (8 in-flight) and reject additional calls with a clear error.
  • Validate command size against maxInputBytes before enqueuing async executions to avoid retaining oversized strings.
  • Update docs and add runtime-compat tests for queue-full rejection and pre-queue input-size validation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
crates/bashkit-js/wrapper.ts Adds JS-side per-instance async queueing, queue cap, and pre-queue input-size checks for Bash, BashTool, and ScriptedTool.
crates/bashkit-js/src/lib.rs Adds Rust-side async execute slot limiting (semaphore) and input-size validation prior to awaiting the per-instance mutex.
crates/bashkit-js/README.md Documents bounded async backlog behavior and pre-queue rejection for oversized inputs.
crates/bashkit-js/__test__/runtime-compat/streaming-output.test.mjs Adds tests for queue-full rejection and maxInputBytes validation for async execute.

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

Comment thread crates/bashkit-js/wrapper.ts
Comment thread crates/bashkit-js/wrapper.ts
Comment thread crates/bashkit-js/wrapper.ts
Comment thread crates/bashkit-js/README.md
chaliy added 3 commits June 12, 2026 10:17
…esult stderr

- executeSync in Bash and BashTool now checks maxInputBytes (same as execute)
- cancelledExecResult returns empty stderr instead of routing through errorExecResult
- document maxInputBytes in BashOptions README section
@chaliy chaliy merged commit f5d2d2b into main Jun 12, 2026
29 checks passed
@chaliy chaliy deleted the fix/pr-2042-js-async-queue branch June 12, 2026 10:52
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.

2 participants