Skip to content

Fix unhandled spawn error reporting - #4129

Merged
codeshaunted merged 17 commits into
canaryfrom
avery/unhandled-spawn-errors
Jul 24, 2026
Merged

codeshaunted merged 17 commits into
canaryfrom
avery/unhandled-spawn-errors

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Issue Reference

Addresses B-405.

Changes

  • Track whether spawned futures are observed and report unreachable errored futures.
  • Add unhandled-spawn callbacks and runtime shutdown to the C bridge ABI.
  • Route unhandled spawn errors through the default host behavior in Node.js, Python, Go, C++, and Java.
  • Add unhandled_spawn_error_uses_host_default in every registered bridge.

Testing

  • cargo test -p bex_engine --all-targets
  • cargo test -p baml_tests --test spawn_semantics
  • cargo test -p bridge_cffi --all-targets
  • cargo test -p bridge_java --all-targets
  • cargo clippy for bridge_cffi, bridge_python, bridge_typescript, and bridge_java
  • Node.js full suite: 113 passed
  • Go full suite passed
  • Java full suite passed
  • C++ full smoke suite passed
  • Python focused regression passed; the full suite retains 6 unrelated existing failures

PR Checklist

  • Unit tests added or updated
  • Code follows project formatting and lint rules
  • Self-review completed
  • No new warnings

Summary by CodeRabbit

  • New Features
    • Added host-delivered “unhandled spawned-task” error reporting, including cancellation status and error traces.
    • Added engine shutdown APIs and cross-language integration points (C/C++, Go, Java, Python, Swift, TypeScript).
    • Added callback support to receive unhandled spawn error envelopes from the runtime.
    • CLI and tests now surface unhandled spawned-task failures via diagnostics and exit codes.
  • Bug Fixes
    • Unobserved spawned errors no longer overwrite successful parent results or fail unrelated awaits.
    • Shutdown/GC handling now preserves and reports unreachable spawned errors more reliably.

@vercel

vercel Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 24, 2026 5:04pm
promptfiddle Ready Ready Preview, Comment Jul 24, 2026 5:04pm
promptfiddle2 Ready Ready Preview, Comment Jul 24, 2026 5:04pm

Request Review

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e0b7db16-8fd9-4a78-af56-34711f285eab

📥 Commits

Reviewing files that changed from the base of the PR and between 23f0315 and 6e15da8.

⛔ Files ignored due to path filters (1)
  • baml_language/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • baml_language/crates/baml_cli/src/run_command.rs
  • baml_language/crates/baml_cli/src/test_command.rs
  • baml_language/crates/baml_cli/tests/exit_code_e2e.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • baml_language/crates/baml_cli/tests/exit_code_e2e.rs
  • baml_language/crates/baml_cli/src/run_command.rs
  • baml_language/crates/baml_cli/src/test_command.rs

📝 Walkthrough

Walkthrough

This change replaces parent-level fire-and-forget error propagation with GC-based unhandled-spawn reporting, adds engine shutdown coordination, extends the CFFI ABI, integrates callback handling across host SDKs, and updates CLI and runtime tests.

Changes

Unhandled spawn lifecycle

Layer / File(s) Summary
Future, GC, and engine delivery
baml_language/crates/bex_vm_types/..., baml_language/crates/bex_heap/..., baml_language/crates/bex_engine/...
Future errors now track observation and cancellation flags; GC preserves unreachable errored futures, while the engine queues, dispatches, and drains unhandled spawn errors during shutdown.
CFFI ABI and runtime bridge
baml_language/crates/bridge_cffi/...
The V1 ABI adds unhandled-spawn callback registration and runtime shutdown, with serialized error delivery and runtime replacement cleanup.
Host SDK integrations
baml_language/sdks/{cpp,go,java,python,typescript,swift}/...
Host bindings register callbacks, expose shutdown operations, and translate unhandled-spawn payloads into native error behavior.
Project, CLI, and packed-host outcomes
baml_language/crates/{bex_project,baml_cli,baml_pack_host}/...
Project replacement, command execution, testing, and packed dispatch shut down engines and account for non-cancelled unhandled spawn failures.
Spawn semantics and validation
baml_language/crates/{baml_tests,bex_engine}/tests/..., baml_language/sdks/*/tests/...
Tests verify that unobserved child errors do not replace parent results and that GC, shutdown, callbacks, cancellation, and host-default handling behave as specified.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SpawnedFuture
  participant BexHeap
  participant BexEngine
  participant CFFIBridge
  participant HostSDK

  SpawnedFuture->>BexHeap: settle unobserved error
  BexHeap->>BexHeap: preserve error during GC
  BexHeap->>BexEngine: drain unhandled spawn error
  BexEngine->>CFFIBridge: encode and dispatch error payload
  CFFIBridge->>HostSDK: invoke registered callback
  HostSDK->>HostSDK: report or raise host-native error
Loading

Possibly related PRs

Poem

A bunny watched a spawned task fly,
Then GC caught its error nearby.
The engine queued it, bridges rang,
Host callbacks made the warning clang.
Shutdown tucked the runtime tight—
“No lost carrot errors tonight!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing unhandled spawn error reporting.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch avery/unhandled-spawn-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel
vercel Bot temporarily deployed to Preview – beps July 22, 2026 21:55 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 22, 2026 22:02 Inactive
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 27.1 MB 11.5 MB file 27.1 MB +35.2 KB (+0.1%) OK
✅ packed-program Linux 🔒 17.4 MB 7.2 MB file 17.4 MB +20.5 KB (+0.1%) OK
✅ baml-cli macOS 🔒 21.0 MB 10.1 MB file 21.0 MB +16.7 KB (+0.1%) OK
✅ packed-program macOS 🔒 13.6 MB 6.3 MB file 13.6 MB +16.6 KB (+0.1%) OK
✅ baml-cli Windows 🔒 22.7 MB 10.3 MB file 22.7 MB +27.6 KB (+0.1%) OK
✅ packed-program Windows 🔒 14.5 MB 6.4 MB file 14.5 MB +14.3 KB (+0.1%) OK
✅ bridge_wasm WASM 16.4 MB 🔒 4.5 MB gzip 4.5 MB +6.5 KB (+0.1%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 6

🧹 Nitpick comments (1)
baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs (1)

7-14: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the forwarded payload and cancellation metadata.

The test only verifies that one callback occurred, drops _cancelled, and never validates the BamlOutboundResult bytes. A malformed payload or incorrect cancellation flag would still pass. Capture the flag, validate/decode the payload, and add a shutdown-cancellation case if needed.

Also applies to: 17-46

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs` around lines 7 -
14, Update the unhandled-spawn test callback capture and assertions around
capture to retain the cancellation flag alongside each payload, decode the
forwarded BamlOutboundResult bytes, and assert their expected contents and
metadata rather than only checking callback count. Add coverage for shutdown
cancellation, asserting the callback reports the expected cancellation value and
payload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/bridge_cffi/src/ffi/unhandled_spawn.rs`:
- Around line 14-34: Update the callback state management in the registration
function and dispatch so callback registration, pending-message draining, and
queueing are coordinated under one shared lock, preventing messages from being
enqueued after the queue is drained. Capture the callback and pending messages
while holding the lock, release it before invoking callbacks, and preserve
existing callback payload behavior. Add a Rust unit test covering the
registration/dispatch handoff and run cargo test --lib.

In `@baml_language/crates/bridge_cffi/src/lib_wasm.rs`:
- Around line 13-31: Add a host-facing drain for UNHANDLED_SPAWN_ERRORS in
lib_wasm.rs, integrating it with the existing callback registration or dispatch
path so queued payloads are reported and removed. Ensure pending errors are
drained when the host callback becomes available and also released during
runtime shutdown, matching the native fallback behavior.

In `@baml_language/sdks/cpp/bridge_cpp/include/baml/runtime.h`:
- Around line 61-71: Update baml_cpp_unhandled_spawn_error_trampoline to call
detail::report_unhandled_spawn_error synchronously instead of creating a
detached thread, preserving payload construction and cancelled conversion.
Explicitly guard the FFI boundary so any exception from reporting is contained
and cannot unwind through the extern "C" function.

In `@baml_language/sdks/go/baml_go/runtime.go`:
- Line 90: Update the initialization failure path immediately after
nativeRegisterUnhandledSpawnErrorCallback so nativeShutdown() is called before
nativeCloseAfterLoadFailure() on every post-registration failure path. Preserve
the callback registration order and ensure no registered callback remains active
when the native library is closed.

In `@baml_language/sdks/python/src/baml_bridge/baml_py.pyi`:
- Line 68: Update the cancellation example around call_function to pass the
attached _ctx variable as the ctx argument instead of ctx, ensuring
BamlCallContext.abort() can cancel the in-flight call.

In `@baml_language/sdks/typescript/bridge_typescript/src/unhandled_spawn.rs`:
- Around line 10-11: Update the shutdown callback delivery associated with
Callback and its deliver path to use ThreadsafeFunctionCallMode::Blocking rather
than NonBlocking, while preserving the weak tsfn configuration for the normal
idle/no-error case so shutdownRuntime waits for the unhandled-spawn report to be
delivered.

---

Nitpick comments:
In `@baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs`:
- Around line 7-14: Update the unhandled-spawn test callback capture and
assertions around capture to retain the cancellation flag alongside each
payload, decode the forwarded BamlOutboundResult bytes, and assert their
expected contents and metadata rather than only checking callback count. Add
coverage for shutdown cancellation, asserting the callback reports the expected
cancellation value and payload.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d84bb99a-6487-486d-bebf-f894dc80baa7

📥 Commits

Reviewing files that changed from the base of the PR and between f1c20aa and ac8b3bc.

⛔ Files ignored due to path filters (14)
  • baml_language/Cargo.lock is excluded by !**/*.lock
  • baml_language/sdks/typescript/bridge_typescript/dist/exit_hook.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/exit_hook.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/exit_hook.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/native.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/native.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/unhandled_spawn.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/unhandled_spawn.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/unhandled_spawn.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/unhandled_spawn.js.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (56)
  • baml_language/crates/baml_tests/tests/spawn_semantics.rs
  • baml_language/crates/bex_engine/Cargo.toml
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/src/thread.rs
  • baml_language/crates/bex_engine/tests/fire_and_forget.rs
  • baml_language/crates/bex_engine/tests/prof_gate.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_heap/src/heap.rs
  • baml_language/crates/bex_heap/src/heap_debugger/real.rs
  • baml_language/crates/bex_heap/src/lib.rs
  • baml_language/crates/bex_project/src/bex.rs
  • baml_language/crates/bex_project/src/lib.rs
  • baml_language/crates/bex_vm/src/package_baml/future.rs
  • baml_language/crates/bex_vm/src/vm.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bridge_cffi/Cargo.toml
  • baml_language/crates/bridge_cffi/cbindgen.toml
  • baml_language/crates/bridge_cffi/include/baml_cffi.h
  • baml_language/crates/bridge_cffi/src/api.rs
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/crates/bridge_cffi/src/ffi/mod.rs
  • baml_language/crates/bridge_cffi/src/ffi/runtime.rs
  • baml_language/crates/bridge_cffi/src/ffi/unhandled_spawn.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/lib_native.rs
  • baml_language/crates/bridge_cffi/src/lib_wasm.rs
  • baml_language/crates/bridge_cffi/tests/abi_assertions.h
  • baml_language/crates/bridge_cffi/tests/abi_layout.c
  • baml_language/crates/bridge_cffi/tests/abi_layout.rs
  • baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs
  • baml_language/sdks/cpp/bridge_cpp/include/baml/detail/loader.h
  • baml_language/sdks/cpp/bridge_cpp/include/baml/runtime.h
  • baml_language/sdks/cpp/bridge_cpp/tests/runtime_smoke.cc
  • baml_language/sdks/go/baml_go/internal/cffi/include/baml_cffi.h
  • baml_language/sdks/go/baml_go/native_unix.go
  • baml_language/sdks/go/baml_go/native_unsupported.go
  • baml_language/sdks/go/baml_go/native_windows.go
  • baml_language/sdks/go/baml_go/runtime.go
  • baml_language/sdks/go/baml_go/runtime_test.go
  • baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/BamlFfi.java
  • baml_language/sdks/java/baml_bridge/src/main/java/baml_bridge/UnhandledSpawnErrors.java
  • baml_language/sdks/java/baml_bridge/src/test/java/baml_bridge/UnhandledSpawnErrorsTest.java
  • baml_language/sdks/java/bridge_java/src/lib.rs
  • baml_language/sdks/python/rust/bridge_python/src/lib.rs
  • baml_language/sdks/python/rust/bridge_python/src/unhandled_spawn.rs
  • baml_language/sdks/python/src/baml_bridge/__init__.py
  • baml_language/sdks/python/src/baml_bridge/baml_py.pyi
  • baml_language/sdks/python/tests/test_engine.py
  • baml_language/sdks/typescript/bridge_typescript/src/lib.rs
  • baml_language/sdks/typescript/bridge_typescript/src/unhandled_spawn.rs
  • baml_language/sdks/typescript/bridge_typescript/tests/unhandled_spawn.test.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/exit_hook.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/native.d.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/unhandled_spawn.ts
💤 Files with no reviewable changes (1)
  • baml_language/crates/bex_heap/src/heap_debugger/real.rs

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 22, 2026 22:16 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 22, 2026 22:37 Inactive

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
baml_language/sdks/typescript/bridge_typescript/tests/unhandled_spawn.test.ts (1)

21-30: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Strengthen the child-process oracle.

The test never verifies that main completed successfully, so any root-call failure can satisfy the expected non-zero exit. Also, spawnSync returns status === null on timeout or signal termination, which not.toBe(0) accepts.

Emit/assert a success marker after result() and verify child.error/child.signal are clear before asserting a numeric non-zero exit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@baml_language/sdks/typescript/bridge_typescript/tests/unhandled_spawn.test.ts`
around lines 21 - 30, Strengthen the child-process assertions around the spawned
script: emit a success marker only after callFunctionSync(...).result()
completes, then assert the marker is present. Before checking the exit code,
assert child.error and child.signal are clear, and require child.status to be a
numeric non-zero value so timeouts or signal termination cannot satisfy the
test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@baml_language/sdks/typescript/bridge_typescript/tests/unhandled_spawn.test.ts`:
- Around line 21-30: Strengthen the child-process assertions around the spawned
script: emit a success marker only after callFunctionSync(...).result()
completes, then assert the marker is present. Before checking the exit code,
assert child.error and child.signal are clear, and require child.status to be a
numeric non-zero value so timeouts or signal termination cannot satisfy the
test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c055555e-293e-4b2f-b6bd-a4c391cc7606

📥 Commits

Reviewing files that changed from the base of the PR and between ac8b3bc and d2a73d4.

⛔ Files ignored due to path filters (4)
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.d.ts.map is excluded by !**/dist/**, !**/*.map
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js is excluded by !**/dist/**
  • baml_language/sdks/typescript/bridge_typescript/dist/index.js.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (12)
  • baml_language/crates/baml_tests/tests/cancel_cascade.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bridge_cffi/src/ffi/unhandled_spawn.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/src/lib_wasm.rs
  • baml_language/sdks/cpp/bridge_cpp/include/baml/runtime.h
  • baml_language/sdks/go/baml_go/runtime.go
  • baml_language/sdks/python/rust/bridge_python/src/baml_call_context.rs
  • baml_language/sdks/python/src/baml_bridge/baml_py.pyi
  • baml_language/sdks/typescript/bridge_typescript/src/unhandled_spawn.rs
  • baml_language/sdks/typescript/bridge_typescript/tests/unhandled_spawn.test.ts
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
💤 Files with no reviewable changes (2)
  • baml_language/sdks/typescript/bridge_typescript/typescript_src/index.ts
  • baml_language/crates/bridge_cffi/src/lib_wasm.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • baml_language/sdks/go/baml_go/runtime.go
  • baml_language/sdks/typescript/bridge_typescript/src/unhandled_spawn.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/sdks/python/src/baml_bridge/baml_py.pyi
  • baml_language/crates/bex_engine/src/lib.rs

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 22, 2026 22:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 22, 2026 22:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 22, 2026 23:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 22, 2026 23:02 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 22, 2026 23:11 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 22, 2026 23:23 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 23, 2026 21:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 23, 2026 21:52 Inactive
…wn-errors

# Conflicts:
#	baml_language/crates/bex_project/src/lib.rs
#	baml_language/sdks/go/baml_go/native_unix.go
#	baml_language/sdks/go/baml_go/native_unsupported.go
#	baml_language/sdks/go/baml_go/native_windows.go
#	baml_language/sdks/go/baml_go/runtime.go
@vercel
vercel Bot temporarily deployed to Preview – beps July 23, 2026 21:54 Inactive

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/bex_engine/src/lib.rs`:
- Around line 2196-2208: The panic recovery in dispatch_unhandled_spawn_errors
must distinguish GC-triggered delivery from normal shutdown delivery. When
collect_garbage invokes it, catch handler panics, record or log the panic, and
do not call resume_unwind; preserve or explicitly discard the queued error so GC
completes without unwinding. Keep existing panic propagation for shutdown or
other paths where it remains required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef156a5c-105a-476b-b99c-3747cc142ced

📥 Commits

Reviewing files that changed from the base of the PR and between e7dc5ed and 8afae59.

⛔ Files ignored due to path filters (1)
  • baml_language/crates/baml_tests/snapshots/baml_src/spawn_throws.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • baml_language/crates/baml_cli/src/run_command.rs
  • baml_language/crates/baml_cli/src/test_command.rs
  • baml_language/crates/baml_pack_host/src/main.rs
  • baml_language/crates/baml_tests/baml_src/ns_spawn_throws/spawn_throws.baml
  • baml_language/crates/bex_engine/src/future.rs
  • baml_language/crates/bex_engine/src/lib.rs
  • baml_language/crates/bex_engine/tests/fire_and_forget.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_heap/src/heap.rs
  • baml_language/crates/bex_project/src/lib.rs
  • baml_language/crates/bex_project/src/project.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs
🚧 Files skipped from review as they are similar to previous changes (8)
  • baml_language/crates/bex_project/src/lib.rs
  • baml_language/crates/bridge_cffi/tests/unhandled_spawn.rs
  • baml_language/crates/bridge_cffi/src/baml_to_host.rs
  • baml_language/crates/bridge_cffi/src/lib.rs
  • baml_language/crates/bex_heap/src/gc.rs
  • baml_language/crates/bex_engine/tests/fire_and_forget.rs
  • baml_language/crates/bex_vm_types/src/types/future.rs
  • baml_language/crates/bex_engine/src/future.rs

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 23, 2026 22:02 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 00:01 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 00:08 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 00:22 Inactive
@codeshaunted

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
baml_language/sdks/java/bridge_java/src/lib.rs (2)

160-170: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add a shutdown timeout for nativeShutdownRuntime.

nativeShutdownRuntime blocks the Java shutdown-hook thread on runtime.block_on(bridge_cffi::shutdown_runtime()), and shutdown_runtime() awaits runtime.shutdown() before draining unhandled spawn errors. If cleanup work can wait on arbitrary spawned futures, this can leave the hook never exiting; bound the wait and propagate any timeout instead of blocking indefinitely.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/java/bridge_java/src/lib.rs` around lines 160 - 170,
Update Java_baml_1bridge_BamlFfi_nativeShutdownRuntime to bound the
runtime.block_on shutdown operation with a timeout, including the subsequent
cleanup performed by bridge_cffi::shutdown_runtime. Propagate a timeout as an
error through the existing throw_runtime_exception path, while preserving
successful shutdown behavior.

160-170: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

No Rust tests to update; add cargo test --lib for the Rust SDK crate.

This package build artifact is a shared library, not a Rust test target. Run cargo test --lib for any associated Rust tests in this project/package.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@baml_language/sdks/java/bridge_java/src/lib.rs` around lines 160 - 170,
Update the Rust SDK package validation to run the library test target with cargo
test --lib, rather than treating the shared-library artifact as a standalone
test target. No Rust test changes are required; ensure the package’s test
configuration or verification instructions invoke cargo test --lib for
associated tests.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@baml_language/sdks/java/bridge_java/src/lib.rs`:
- Around line 160-170: Update Java_baml_1bridge_BamlFfi_nativeShutdownRuntime to
bound the runtime.block_on shutdown operation with a timeout, including the
subsequent cleanup performed by bridge_cffi::shutdown_runtime. Propagate a
timeout as an error through the existing throw_runtime_exception path, while
preserving successful shutdown behavior.
- Around line 160-170: Update the Rust SDK package validation to run the library
test target with cargo test --lib, rather than treating the shared-library
artifact as a standalone test target. No Rust test changes are required; ensure
the package’s test configuration or verification instructions invoke cargo test
--lib for associated tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 381c46eb-e8d5-4b86-b68a-1f114c5dbe34

📥 Commits

Reviewing files that changed from the base of the PR and between 69f1855 and 311a27a.

📒 Files selected for processing (4)
  • baml_language/sdks/cpp/bridge_cpp/include/baml/runtime.h
  • baml_language/sdks/java/bridge_java/src/lib.rs
  • baml_language/sdks/python/src/baml_bridge/__init__.py
  • baml_language/sdks/python/tests/test_engine.py

@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 02:22 Inactive

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@baml_language/crates/baml_cli/src/test_command.rs`:
- Around line 616-619: Restructure the list-mode flow around collect_tests, the
listing logic, and the cache-verification block so finish_engine(&run_ctx) runs
before any discovery cache write or return. Evaluate shutdown errors
consistently, return TestFailure when finishing fails, and ensure every
list-mode success or error path shuts down the engine before returning,
preventing failed discovery results from being cached.

In `@baml_language/sdks/python/tests/test_engine.py`:
- Around line 109-117: Update the subprocess test’s post-run fallback after the
expected termination check to exit with a distinct sentinel status instead of
raising AssertionError, while retaining the assertion that os._exit(1) produces
return code 1. This ensures a handler that prints “boom” and returns cannot
satisfy the test accidentally.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: df43eac7-a714-47a9-8596-d91a8e7221ce

📥 Commits

Reviewing files that changed from the base of the PR and between 311a27a and de2f1bf.

📒 Files selected for processing (4)
  • baml_language/crates/baml_cli/src/test_command.rs
  • baml_language/crates/baml_cli/tests/exit_code_e2e.rs
  • baml_language/sdks/python/src/baml_bridge/__init__.py
  • baml_language/sdks/python/tests/test_engine.py

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 02:29 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 02:43 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 02:45 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 02:52 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 03:03 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 03:06 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 03:13 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 03:25 Inactive
…wn-errors

# Conflicts:
#	baml_language/.cargo/size-gate.toml
#	baml_language/.ci/size-gate/aarch64-apple-darwin.toml
#	baml_language/.ci/size-gate/x86_64-pc-windows-msvc.toml
#	baml_language/crates/baml_cli/src/test_command.rs
@vercel
vercel Bot temporarily deployed to Preview – beps July 24, 2026 16:44 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 24, 2026 16:51 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 24, 2026 17:04 Inactive
@codeshaunted
codeshaunted added this pull request to the merge queue Jul 24, 2026
Merged via the queue into canary with commit af29aa2 Jul 24, 2026
80 checks passed
@codeshaunted
codeshaunted deleted the avery/unhandled-spawn-errors branch July 24, 2026 18:14

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — 6e15da87 Deployed Jul 24, 2026 by vercel[bot]
Preview – promptfiddle2 — 6e15da87 Deployed Jul 24, 2026 by vercel[bot]
Preview – beps — 6e15da87 Deployed Jul 24, 2026 by vercel[bot]
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.

1 participant