Skip to content

Commit cc4e8be

Browse files
authored
fix(release-tool): use HTTP/2-specific timeouts for GraphQL queries (#169)
* feat: add GoReleaser with automated version bumping - Add .goreleaser.yml with multi-platform build config - Create release.yaml workflow with workflow_dispatch trigger - Support manual version input or auto-bump (patch/minor/major) - Auto-creates and pushes git tag - Builds release-tool binaries for linux/darwin/windows (amd64/arm64) - Auto-generates changelog from commits - Publishes binaries to GitHub releases Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com> * fix(release-tool): use HTTP/2-specific timeouts for GraphQL queries Replaces http.Transport with http2.Transport to properly handle timeouts for GitHub's GraphQL API which uses HTTP/2. Issue: http.Transport.IdleConnTimeout is ignored by HTTP/2 connections, causing stream cancellation after ~11 seconds during long queries. Solution: Use http2.Transport with ReadIdleTimeout and PingTimeout to prevent stream cancellation by sending ping frames during long-running queries (500+ commits). Refs: https://github.com/Kong/kong-mesh/actions/runs/20380687072 Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com> --------- Signed-off-by: Marcin Skalski <skalskimarcin33@gmail.com>
1 parent 65e59ee commit cc4e8be

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

cmd/internal/github/graphql.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/Masterminds/semver/v3"
1515
"github.com/google/go-github/v79/github"
16+
"golang.org/x/net/http2"
1617
)
1718

1819
type GQLOutput struct {
@@ -147,15 +148,15 @@ func NewGQLClient(useGHAuth bool) (*GQLClient, error) {
147148

148149
cl := github.NewClient(nil).WithAuthToken(token)
149150

150-
// Configure HTTP client with appropriate timeouts for large GraphQL queries
151-
// This prevents stream cancellation errors when fetching large changelogs
151+
// Configure HTTP client with HTTP/2-specific timeouts for large GraphQL queries
152+
// GitHub's GraphQL API uses HTTP/2, which requires http2.Transport for proper timeout handling
153+
// ReadIdleTimeout prevents stream cancellation during long-running queries (500+ commits)
154+
// by sending ping frames to keep the connection alive
152155
httpClient := &http.Client{
153156
Timeout: 5 * time.Minute,
154-
Transport: &http.Transport{
155-
ResponseHeaderTimeout: 2 * time.Minute,
156-
ExpectContinueTimeout: 1 * time.Second,
157-
// Increase idle connection timeout for long-running queries
158-
IdleConnTimeout: 90 * time.Second,
157+
Transport: &http2.Transport{
158+
ReadIdleTimeout: 5 * time.Minute,
159+
PingTimeout: 30 * time.Second,
159160
},
160161
}
161162

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ require (
77
github.com/google/go-github/v79 v79.0.0
88
github.com/hashicorp/go-multierror v1.1.1
99
github.com/spf13/cobra v1.10.1
10-
golang.org/x/term v0.37.0
10+
golang.org/x/net v0.48.0
11+
golang.org/x/term v0.38.0
1112
gopkg.in/yaml.v3 v3.0.1
1213
)
1314

@@ -16,5 +17,6 @@ require (
1617
github.com/hashicorp/errwrap v1.1.0 // indirect
1718
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1819
github.com/spf13/pflag v1.0.10 // indirect
19-
golang.org/x/sys v0.38.0 // indirect
20+
golang.org/x/sys v0.39.0 // indirect
21+
golang.org/x/text v0.32.0 // indirect
2022
)

go.sum

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@ github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4
2121
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
2222
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
2323
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
24-
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
25-
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
26-
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
27-
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
24+
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
25+
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
26+
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
27+
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
28+
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
29+
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
30+
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
31+
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
2832
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
2933
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
3034
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)