BoundaryML/baml · error

failed to get SSE chunks: %w

Error message

failed to get SSE chunks: %w

What it means

llmStreamCall.SSEChunks() calls the native "sse_chunks" method; any error from that FFI invocation is wrapped as "failed to get SSE chunks: %w". It signals the runtime could not return the chunk list for this stream call handle.

Source

Thrown at engine/language_client_go/pkg/rawobjects_llm_stream_call.go:26

	"github.com/boundaryml/baml/engine/language_client_go/pkg/cffi"
)

type llmStreamCall struct {
	*llmCall
}

func newLLMStreamCall(ptr int64, rt unsafe.Pointer) LLMStreamCall {
	return &llmStreamCall{&llmCall{raw_objects.FromPointer(ptr, rt)}}
}

func (l *llmStreamCall) ObjectType() cffi.BamlObjectType {
	return cffi.BamlObjectType_OBJECT_LLM_STREAM_CALL
}

func (l *llmStreamCall) SSEChunks() ([]SSEResponse, error) {
	result, err := raw_objects.CallMethod(l, "sse_chunks", nil)
	if err != nil {
		return nil, fmt.Errorf("failed to get SSE chunks: %w", err)
	}

	casted, ok := result.([]raw_objects.RawPointer)
	if !ok {
		return nil, fmt.Errorf("unexpected type for SSE chunks: %T", result)
	}

	chunks := make([]SSEResponse, len(casted))
	for i, chunk := range casted {
		chunks[i] = chunk.(SSEResponse)
	}

	return chunks, nil
}

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Read the wrapped cause to identify the FFI failure
  2. Collect SSEChunks() while the stream/runtime is still alive
  3. Re-run the stream and read chunks from the new stream call
  4. Match generated client and native runtime versions

Example fix

// before
chunks, err := streamCall.SSEChunks()
// after
chunks, err := streamCall.SSEChunks()
if err != nil {
    return fmt.Errorf("sse chunks unavailable: %w", err)
}
Defensive patterns

Strategy: try-catch

Try / catch

// Go
chunks, err := streamCall.SSEChunks()
if err != nil {
    return fmt.Errorf("sse chunks unavailable: %w", err)
}

Prevention

When it happens

Trigger: Calling SSEChunks() on an llmStreamCall whose native object was invalidated, after stream teardown, or when the runtime errors internally while collecting chunks.

Common situations: Reading chunks after the BAML runtime shut down; using a stream call from an aborted/failed stream; native library and generated client version mismatch.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/fa49d5ae643e3d2d. Report an issue: GitHub.