Skip to content

fix(bindings): reject same-instance callback re-entry#1331

Merged
chaliy merged 2 commits intomainfrom
fix/issue-1320-external-handler-reentrancy
Apr 16, 2026
Merged

fix(bindings): reject same-instance callback re-entry#1331
chaliy merged 2 commits intomainfrom
fix/issue-1320-external-handler-reentrancy

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 16, 2026

Summary

  • reject same-instance external_handler re-entry in the Python bindings before it can block on the interpreter mutex
  • reject same-instance onOutput re-entry in the JS bindings, including pre-obtained fs() handles and sync executeSync() callbacks
  • add regression coverage for both binding paths and document the JS callback contract clearly

Root Cause

Both bindings delivered user callbacks while the same Bash instance was still mid-execution and still owned the interpreter/runtime access needed by live methods. If the callback re-entered the same instance through execute*, read_file / readFile, or fs(), the binding tried to reacquire that state and either hung or panicked instead of failing cleanly.

Validation

  • just pre-pr
  • node --test crates/bashkit-js/__test__/runtime-compat/streaming-output.test.mjs
  • targeted Python binding checks for re-entrant handler access and existing external handler coverage

Closes #1320

@chaliy chaliy changed the title fix(python): reject external handler re-entry fix(bindings): reject same-instance callback re-entry Apr 16, 2026
@chaliy chaliy marked this pull request as ready for review April 16, 2026 20:28
@chaliy chaliy merged commit 7772dff into main Apr 16, 2026
32 checks passed
@chaliy chaliy deleted the fix/issue-1320-external-handler-reentrancy branch April 16, 2026 21:39
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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(python): external_handler deadlocks when callback re-enters same Bash instance

1 participant