[Bug] Missing stream.Close() in processStreamingOutput causes potential resource leaks

Author: uschenCreated Feb 7, 2026Updated Feb 19, 2026
LabelsBug

Hi team,

https://github.com/awsdocs/aws-doc-sdk-examples/blob/12ee8a27fa96b7a944d1b22f58ca36ac5b4dcdc5/gov2/bedrock-runtime/actions/invoke_model_with_response_stream.go#L107

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.

Source: awsdocs/aws-doc-sdk-examples