bugsnag / bugsnag-go

Automatic panic monitoring for Go and Go web frameworks, like negroni, gin, and revel
https://docs.bugsnag.com/platforms/go
MIT License
204 stars 69 forks source link

Program cannot be interrupted when `bugsnag-go` is imported #249

Closed shanesmith closed 1 month ago

shanesmith commented 1 month ago

Describe the bug

With bugsnag-go imported the program cannot be interrupted (ie: Ctrl-C).

This was introduced in https://github.com/bugsnag/bugsnag-go/pull/231, specifically with this line:

signal.Notify(signalsCh, syscall.SIGINT, syscall.SIGTERM)

This traps SIGINT and sends a signal to the channel, but will also disable the default handling of the signal which is to kill the program.

Also note that the issue is encountered as soon as the bugsnag-go module is imported, the module doesn't otherwise need to be actually used.

Steps to reproduce

go.mod ``` module foo go 1.23.2 require ( github.com/bugsnag/bugsnag-go/v2 v2.5.0 // indirect github.com/bugsnag/panicwrap v1.3.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect github.com/pkg/errors v0.9.1 // indirect ) ```
go.sum ``` github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/bugsnag/bugsnag-go/v2 v2.5.0 h1:kOf+3Rlv7KRrgaYj26GKvSntVeJrB2xQXvqfK0efojA= github.com/bugsnag/bugsnag-go/v2 v2.5.0/go.mod h1:S9njhE7l6XCiKycOZ2zp0x1zoEE5nL3HjROCSsKc/3c= github.com/bugsnag/panicwrap v1.3.4 h1:A6sXFtDGsgU/4BLf5JT0o5uYg3EeKgGx3Sfs+/uk3pU= github.com/bugsnag/panicwrap v1.3.4/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 h1:iQTw/8FWTuc7uiaSepXwyf3o52HaUYcV+Tu66S3F5GA= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= ```
// main.go
package main

import (
  "fmt"
  "time"

  _ "github.com/bugsnag/bugsnag-go/v2"
)

func main() {
  fmt.Println("Waiting...")
  time.Sleep(10 * time.Second)
  fmt.Println("...done")
}
$ go run main.go
Waiting...
^C...done

Environment

RobertoSmartBear commented 1 month ago

Hi @shanesmith ,

Thanks for bringing this to our attention. Our engineers were able to reproduce the problem and found the fix. It will likely be released next week, and we'll let you know here on the thread when it happens.

shanesmith commented 1 month ago

Amazing, much appreciated!

mclack commented 1 month ago

Hi @shanesmith

We have now released v2.5.1 of bugsnag-go which removes our usage of signal.Notify, and should resolve this issue: https://github.com/bugsnag/bugsnag-go/releases/tag/v2.5.1

I hope that helps. Please do let us know if you continue to notice any issues after upgrading bugsnag-go.