You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: Suppress spurious "failed to close HTTP response body" SDK warning in test output #229
When using StartTestServer in tests, the AWS SDK v2 emits the following warning to stderr for nearly every request:
SDK 2026/03/19 17:15:05 WARN failed to close HTTP response body, this may affect connection reuse
This is noisy and clutters go test -v output. It appears on DynamoDB PutItem, Query, UpdateItem, DeleteItem, and EC2 calls — essentially any operation where the response body is not explicitly drained and closed by the plugin's response writer.
Root cause
The AWS SDK v2 logs this warning when resp.Body.Close() returns an error or when the body is not fully drained before closing, which prevents HTTP keep-alive connection reuse. The Substrate test server likely closes the connection or returns a body that the SDK cannot cleanly drain.
Expected behaviour
No spurious warnings in test output. Either:
Substrate's response writer ensures response bodies are fully readable and cleanly closeable, or
The TestServer suppresses SDK-level logging during tests (e.g. by setting aws.NopLogger on the config returned/used internally)
Reproduction
funcTestRepro(t*testing.T) {
env:=substrate.StartTestServer(t)
cfg, _:=awsconfig.LoadDefaultConfig(context.Background(),
awsconfig.WithBaseEndpoint(env.URL),
awsconfig.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("test","test","test")),
)
ddb:=dynamodb.NewFromConfig(cfg)
// Any PutItem/Query call produces the warningddb.PutItem(context.Background(), &dynamodb.PutItemInput{...})
}
Context
Observed in spore-host/spawn tests after migrating from hand-written mocks to Substrate (related to issue #228).
Activity