-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen: Add fix to prevent HTTP/2 event stream request hang on error (…
…#4288) Adds fix addressing an issue where SDK's bi-directional eventstream API operation request could hang when the HTTP/2 stream was closed by the service with a non-200 status code. Go 1.15 through 1.17 have an issue where the HTTP/2 request can hang while waiting for the HTTP response, and input payload reader. The Expect: 100-Continue workaround forces the HTTP client to wait for a `100 continue` or other HTTP status code before attempting to wait for the request's body to be read. This workaround is not needed for Go 1.18, as a fix to the HTTP client resolves this issue. Related to aws/aws-sdk-go-v2#1515
- Loading branch information
Showing
7 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
package eventstreamapi | ||
|
||
import "github.com/aws/aws-sdk-go/aws/request" | ||
|
||
// This is a no-op for Go 1.18 and above. | ||
func ApplyHTTPTransportFixes(r *request.Request) { | ||
} |
19 changes: 19 additions & 0 deletions
19
private/protocol/eventstream/eventstreamapi/transport_go1.17.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//go:build !go1.18 | ||
// +build !go1.18 | ||
|
||
package eventstreamapi | ||
|
||
import "github.com/aws/aws-sdk-go/aws/request" | ||
|
||
// ApplyHTTPTransportFixes applies fixes to the HTTP request for proper event | ||
// stream functionality. Go 1.15 through 1.17 HTTP client could hang forever | ||
// when an HTTP/2 connection failed with an non-200 status code and err. Using | ||
// Expect 100-Continue, allows the HTTP client to gracefully handle the non-200 | ||
// status code, and close the connection. | ||
// | ||
// This is a no-op for Go 1.18 and above. | ||
func ApplyHTTPTransportFixes(r *request.Request) { | ||
r.Handlers.Sign.PushBack(func(r *request.Request) { | ||
r.HTTPRequest.Header.Set("Expect", "100-Continue") | ||
}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package lexruntimev2 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/awserr" | ||
"github.com/aws/aws-sdk-go/awstesting/integration" | ||
) | ||
|
||
func TestInteg_StartConversation_errorCase(t *testing.T) { | ||
sess := integration.SessionWithDefaultRegion("us-west-2") | ||
|
||
client := New(sess, &aws.Config{ | ||
Logger: t, | ||
LogLevel: aws.LogLevel(aws.LogDebugWithEventStreamBody | aws.LogDebugWithHTTPBody), | ||
}) | ||
|
||
_, err := client.StartConversation(&StartConversationInput{ | ||
BotAliasId: aws.String("mockAlias"), | ||
BotId: aws.String("mockId01234567890"), | ||
LocaleId: aws.String("mockLocale"), | ||
SessionId: aws.String("mockSession"), | ||
}) | ||
if err == nil { | ||
t.Fatalf("expect error, got none") | ||
} | ||
|
||
aErr, ok := err.(awserr.RequestFailure) | ||
if !ok { | ||
t.Fatalf("expect %T error, got %T, %v", aErr, err, err) | ||
} | ||
if aErr.Code() == "" { | ||
t.Errorf("expect error code, got none") | ||
} | ||
if aErr.Message() == "" { | ||
t.Errorf("expect error message, got none") | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.