Open
Description
Describe the bug
A default configuration of bugsnag (Synchronous = false) will drop notify reports if the app exits.
There does not appear to be any way to flush these notify reports, or to delay the exit of the application until they have been sent.
Steps to reproduce
package main
import (
"context"
"errors"
"fmt"
"github.com/bugsnag/bugsnag-go/v2"
)
func main() {
bugsnag.Configure(bugsnag.Configuration{APIKey: "***"})
ctx := bugsnag.StartSession(context.Background())
err := errors.New("my error")
berr := bugsnag.Notify(err, ctx)
if berr != nil {
panic(berr)
}
fmt.Println("done")
}
The above golang application will print "done", but no bugs will show up in bugsnag.
If you add time.Sleep(120*time.Second)
to the end of it, the bugs will start showing up in bugsnag.
Bugsnag should probably have a buffered channel accumulating errors, with a worker pool publishing the channels to bugsnag's servers. There should be a function you can call that waits for the channel to be empty, or closes the channel and waits for the workers to finish consuming from the channel and exit.
Environment
- Bugsnag Go version: v2.2.0
- Go version: v1.21.0