Skip to content

Commit

Permalink
bugfix: build upon default sentry-go transport config (#3643)
Browse files Browse the repository at this point in the history
Directly initializing the NewHTTPSyncTransport struct results in the non-exported limits map being nil, which can cause a panic in sentry-go under certain conditions
  • Loading branch information
RaghavSood committed Jun 18, 2024
1 parent dd3c03f commit 069b987
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/sentry/sentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ var initError error // set during init
type Context = sentry.Context

func init() {
// Set the timeout on the default HTTPSyncTransport to 3 seconds
// This is used over initializing the struct directly as we can't
// set non-exported fields such as transport.limits to a non-nil
// value, which can result in panics in sentry-go.
transport := sentry.NewHTTPSyncTransport()
transport.Timeout = 3 * time.Second

opts := sentry.ClientOptions{
Dsn: "https://89fa584dc19b47a6952dd94bf72dbab4@sentry.io/4492967",
// TODO: maybe set Debug to buildinfo.IsDev?
// Debug: true,
Environment: buildinfo.Environment(),
Release: "v" + buildinfo.Version().String(),
Transport: &sentry.HTTPSyncTransport{
Timeout: 3 * time.Second,
},
Transport: transport,
BeforeSend: func(event *sentry.Event, _ *sentry.EventHint) *sentry.Event {
if buildinfo.IsDev() {
return nil
Expand Down

0 comments on commit 069b987

Please sign in to comment.