BoundaryML/baml · error · RuntimeError
{e:?}
Error message
{e:?} What it means
FunctionResultStream#done finalizes a stream and produces the complete FunctionResult. If the underlying Rust call returns Err, the error is formatted with {e:?} and raised as a Ruby RuntimeError — so the message is the debug dump of the internal failure.
Source
Thrown at engine/language_client_ruby/ext/ruby_ffi/src/function_result_stream.rs:49
let proc = ruby.block_proc()?;
Some(move |event: baml_runtime::FunctionResult| {
// ignore errors if they happen
let _ = proc.call::<_, magnus::Value>((FunctionResult::new(event),));
})
} else {
None
};
match rb_self.t.block_on(rb_self.inner.borrow_mut().run(
None::<fn()>,
on_event,
&ctx.inner,
None,
None,
HashMap::new(),
)) {
(Ok(res), _) => Ok(FunctionResult::new(res)),
(Err(e), _) => Err(Error::new(ruby.exception_runtime_error(), format!("{e:?}"))),
}
}
/// For usage in magnus::init
///
/// TODO: use traits and macros to implement this
pub fn define_in_ruby(module: &RModule) -> Result<()> {
let cls = module.define_class("FunctionResultStream", class::object())?;
cls.define_method("done", method!(FunctionResultStream::done, 1))?;
Ok(())
}
}
View on GitHub (pinned to bd85ce9dee)
Solutions
- Read the {e:?} detail to identify the underlying provider error
- Wrap .done in begin/rescue RuntimeError and retry the stream
- Configure retry/fallback strategies on the BAML client
- Check API key validity and network stability for streaming
Example fix
// before
final = stream.done
// after
final =
begin
stream.done
rescue RuntimeError => e
warn "Stream failed: #{e.message}"
nil
end Defensive patterns
Strategy: retry
Try / catch
begin
final = stream.done
rescue RuntimeError => e
logger.error("stream failed: #{e.message}")
final = retry_stream_once
end Prevention
- Wrap stream.finalize/done in retry logic
- Verify API keys and network before long streams
- Use BAML retry policies so transient stream errors self-heal
When it happens
Trigger: Calling .done on a stream after the LLM request failed (network error, provider 4xx/5xx, cancelled stream), or when aggregate parsing of accumulated partials fails.
Common situations: Streaming calls that die mid-flight due to connectivity issues, exhausted retries, or invalid API keys surfaced only at done() time.
Related errors
- Failed to stream function: {}
- failed to get SSE chunks: %w
- unexpected type for SSE chunks: %T
- failed to get text: %w
- getattr(StreamState)
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/760022639e33617b.
Report an issue: GitHub.