fix(js): bound async execute queue and validate input size before queueing#2062
Merged
Conversation
Deploying with
|
| 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 |
There was a problem hiding this comment.
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
maxInputBytesbefore 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.
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 validatesmaxInputBytesbefore the call enters the queue, and forwardsmaxInputBytesthroughtoNativeOptionsso the Rust core enforces the same limit.