Skip to content

Existing async notify reports disappear if app exits. No apparent way to flush them. #200

Open
@veqryn

Description

@veqryn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting feedbackAwaiting a response from a customer. Will be automatically closed after approximately 2 weeks.backlogWe hope to fix this feature/bug in the futurefeature requestRequest for a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions