-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
Bug Description
Running app normally w/ Listen -- context is fine, so I can use it for my db queries.
fmt.Printf("%+v // %+v\n", c.Context(), c.Context().Err())
// #0000000100000001 - 127.0.0.1:8081<->127.0.0.1:48162 - GET http://0.0.0.0:8081/test // <nil>Running a test on the same app -- and context is cancelled upon creation
fmt.Printf("%+v // %+v\n", c.Context(), c.Context().Err())
// #0000000100000001 - 0.0.0.0:0<->0.0.0.0:0 - GET http://example.com/test // context canceledHow to Reproduce
- Create new app
- Create any handler
- Print context and it's Err()
See code snippet below
Expected Behavior
Context in both prod and test should be initialized as not Done, w/o any errors.
Fiber Version
v3.0.0-beta.3
Code Snippet (optional)
// main.go
package main
import (
"fmt"
"github.com/gofiber/fiber/v3"
)
func main() {
app := newApp()
app.Listen(":8081")
}
func newApp() *fiber.App {
app := fiber.New()
app.Get("/test", func(c fiber.Ctx) error {
fmt.Printf("%+v // %+v\n", c.Context(), c.Context().Err())
return c.SendString("ok")
})
return app
}
// main_test.go
package main
import (
"net/http/httptest"
"testing"
)
func TestMain(t *testing.T) {
app := newApp()
req := httptest.NewRequest("GET", "/test", nil)
_, err := app.Test(req, -1)
if err != nil {
t.Fatal(err)
}
}Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.
Reactions are currently unavailable
