Skip to content

fix(js): use shared runtime and concurrency limit for tool callbacks#1047

Merged
chaliy merged 3 commits intomainfrom
fix/issue-982-thread-pool-callbacks
Apr 4, 2026
Merged

fix(js): use shared runtime and concurrency limit for tool callbacks#1047
chaliy merged 3 commits intomainfrom
fix/issue-982-thread-pool-callbacks

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Replace unbounded std::thread::spawn + per-call Runtime::new() with a shared lazily-initialized tokio runtime (2 worker threads)
  • Add semaphore with 10 permits to cap concurrent in-flight tool callbacks
  • Prevents OS thread exhaustion from scripts invoking tools in loops

Test plan

  • Tool callbacks still execute correctly
  • Concurrent tool invocations bounded by semaphore
  • cargo check -p bashkit-js passes
  • No thread exhaustion under heavy tool callback load

Closes #982

chaliy added 3 commits April 3, 2026 23:30
Replace unbounded std::thread::spawn + per-invocation tokio runtime with
a shared lazily-initialized multi-thread runtime and a semaphore capping
concurrent tool callbacks at 10. Prevents DoS via runaway thread creation
when scripts invoke registered tools in tight loops.

Closes #982
@chaliy chaliy merged commit 77b0693 into main Apr 4, 2026
20 checks passed
@chaliy chaliy deleted the fix/issue-982-thread-pool-callbacks branch April 4, 2026 01:15
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.

Unbounded thread creation in ScriptedTool JS callbacks enables DoS

1 participant