Hi team,
|
for event := range output.GetStream().Events() { |
While this works perfectly for the CLI use case, Close() isn't called on the event stream. The SDK documentation notes this is required to clean up the underlying reader/writer.
If customers copy this snippet into a long-running web server (instead of a CLI), it will leak goroutines. Adding a defer stream.Close() would make this safe for copy-pasting into production apps.
Hi team,
aws-doc-sdk-examples/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go
Line 107 in 12ee8a2
While this works perfectly for the CLI use case,
Close()isn't called on the event stream. The SDK documentation notes this is required to clean up the underlying reader/writer.If customers copy this snippet into a long-running web server (instead of a CLI), it will leak goroutines. Adding a defer
stream.Close()would make this safe for copy-pasting into production apps.