-
Notifications
You must be signed in to change notification settings - Fork 242
Closed
Labels
ImprovementIssue typeIssue type
Description
Summary
You iterate over a channel in a separate goroutine. This channel is never closed which leads to a goroutine leak.
Steps To Reproduce
Install "go.uber.org/goleak"
and add the following code to transport_test.go
file
package sentry
import (
...
"go.uber.org/goleak"
)
...
func TestHTTPTransportDoesntLeakGoroutines(t *testing.T) {
// verify that we're not leaking any goroutine
defer goleak.VerifyNone(t)
// init and configure transport
transport := NewHTTPTransport()
transport.Configure(ClientOptions{
Dsn: "https://test@foobar/1",
HTTPClient: http.DefaultClient,
})
// use transport if needed
// the transport is not needed anymore, get rid of it
transport = nil
// do some other work here
}
output:
=== RUN TestHTTPTransportDoesntLeakGoroutines
transport_test.go:701: found unexpected goroutines:
[Goroutine 20 in state chan receive, with github.com/getsentry/sentry-go.(*HTTPTransport).worker on top of the stack:
goroutine 20 [chan receive]:
github.com/getsentry/sentry-go.(*HTTPTransport).worker(0x140002478f0)
/path/to/sentry-go/transport.go:471 +0xb8
created by github.com/getsentry/sentry-go.(*HTTPTransport).Configure.func1 in goroutine 19
/path/to/sentry-go/transport.go:343 +0x60
]
Expected Behavior
As a user, I want to be able to tear down all the sentry-allocated resources when it's no longer needed.
SDK
sentry-go
version: v0.25.0- Go version: go version go1.20.9
- Using Go Modules? yes
eugeneradionov and aine-etke
Metadata
Metadata
Assignees
Labels
ImprovementIssue typeIssue type