Closed joeyagreco-sb closed 4 months ago
When calling Response.Exit(), code hangs.
Response.Exit()
Example for reproduction:
Set shouldExit to true, and the test hangs. Set shouldExit to false and the test does not hang.
shouldExit
true
false
package main import ( "errors" "fmt" "net/http" "testing" "github.com/Kong/go-pdk" "github.com/stretchr/testify/assert" k "github.com/Kong/go-pdk/test" ) type foo struct { shouldExit bool } func New() *foo { return &foo{ // manually change me to see both ways shouldExit: true, } } func (f *foo) Response(kong *pdk.PDK) { if f.shouldExit { fmt.Println("im trying to exit early") kong.Response.Exit(http.StatusInternalServerError, []byte(errors.New("exit").Error()), nil) } fmt.Println("im done") } func TestFoo(t *testing.T) { t.Parallel() env, err := k.New(t, k.Request{ Method: "POST", Url: "", Body: []byte("{}"), }) assert.NoError(t, err) env.DoHttps(New()) }
I will note that kong.Response.ExitStatus() does not hang.
kong.Response.ExitStatus()
Fixed by #174
When calling
Response.Exit()
, code hangs.Example for reproduction:
Set
shouldExit
totrue
, and the test hangs. SetshouldExit
tofalse
and the test does not hang.I will note that
kong.Response.ExitStatus()
does not hang.