-
Notifications
You must be signed in to change notification settings - Fork 358
Description
Product
BAML
Describe the bug
The generated parse and parse_stream methods in the Golang client call bamlRuntime.CallFunctionParse with a context.Background(), and CallFunctionParse unconditionally spawns a goroutine that waits for the context to be done (link), but since nothing else can make that goroutine stop, and context.Background() will never complete, the goroutine leaks.
This pattern of "wait for context to be done" goroutines appears in bamlRuntime.CallFunction as well, but at least there the context is user-controlled, so the goroutine leak is "avoidable", but definitely still realistic, especially considering the fact that BAML docs encourage the usage of context.Background() through the official examples.
Reproduction Steps
- Set up a Go BAML project with some goroutine profiling mechanism like pprof
- Run some BAML functions
- Observe the multiple leaked goroutines via your profiling mechanism of choice, e.g.:
BAML Version
Identified on 0.214.0, evidently present in latest as well judging by the code
Language/Framework
Go
LLM Provider
None
LLM Model
No response
Operating System
None
Browser
None
Code Editor
None