Bug Description
This works
while this cause race condition:
app.Use(
logger.New(logger.Config{
Format: "${time} | ${pid} | ${locals:requestid} | ${status} | ${latency} | ${method} | ${path}\n",
}),
)
WARNING: DATA RACE
Read at 0x00c000091230 by goroutine 14:
github.com/gofiber/fiber/v2/middleware/logger.New.func3()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/middleware/logger/logger.go:183 +0x1504
github.com/gofiber/fiber/v2.(*App).next()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/router.go:134 +0x4b6
github.com/gofiber/fiber/v2.(*App).handler()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/router.go:160 +0xf2
github.com/gofiber/fiber/v2.(*App).handler-fm()
<autogenerated>:1 +0x44
github.com/valyala/fasthttp.(*Server).serveConn()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/server.go:2371 +0x1b4a
github.com/valyala/fasthttp.(*Server).serveConn-fm()
<autogenerated>:1 +0x4d
github.com/valyala/fasthttp.(*workerPool).workerFunc()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:224 +0xee
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:196 +0x53
Previous write at 0x00c000091230 by goroutine 13:
github.com/gofiber/fiber/v2/middleware/logger.New.func3()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/middleware/logger/logger.go:179 +0x1364
github.com/gofiber/fiber/v2.(*App).next()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/router.go:134 +0x4b6
github.com/gofiber/fiber/v2.(*App).handler()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/router.go:160 +0xf2
github.com/gofiber/fiber/v2.(*App).handler-fm()
<autogenerated>:1 +0x44
github.com/valyala/fasthttp.(*Server).serveConn()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/server.go:2371 +0x1b4a
github.com/valyala/fasthttp.(*Server).serveConn-fm()
<autogenerated>:1 +0x4d
github.com/valyala/fasthttp.(*workerPool).workerFunc()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:224 +0xee
github.com/valyala/fasthttp.(*workerPool).getCh.func1()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:196 +0x53
Goroutine 14 (running) created at:
github.com/valyala/fasthttp.(*workerPool).getCh()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:195 +0x364
github.com/valyala/fasthttp.(*workerPool).Serve()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:148 +0x7f1
github.com/valyala/fasthttp.(*Server).Serve()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/server.go:1832 +0x850
github.com/gofiber/fiber/v2.(*App).Listen()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/listen.go:82 +0x1d6
main.main()
C:/Users/LorenzoPongetti/Desktop/work/lorenzo/proji/test.go:23 +0x16c
Goroutine 13 (running) created at:
github.com/valyala/fasthttp.(*workerPool).getCh()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:195 +0x364
github.com/valyala/fasthttp.(*workerPool).Serve()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/workerpool.go:148 +0x7f1
github.com/valyala/fasthttp.(*Server).Serve()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/valyala/fasthttp@v1.45.0/server.go:1832 +0x850
github.com/gofiber/fiber/v2.(*App).Listen()
C:/Users/LorenzoPongetti/go/pkg/mod/github.com/gofiber/fiber/v2@v2.42.0/listen.go:82 +0x1d6
main.main()
C:/Users/LorenzoPongetti/Desktop/work/lorenzo/proji/test.go:23 +0x16c
==================
How to Reproduce
func main() {
app := fiber.New()
// add middlewares
app.Use(
logger.New(logger.Config{
Format: "${time} | ${pid} | ${locals:requestid} | ${status} | ${latency} | ${method} | ${path}\n",
}),
)
api := app.Group("api/v1")
api.Get("/test", func(c *fiber.Ctx) error {
return c.SendString("Hello, World 👋!")
})
app.Listen(":3000")
}
and do
seq 1 200 | xargs -n1 -P20 curl "http://172.31.240.1:3000/api/v1/test"
Expected Behavior
┌───────────────────────────────────────────────────┐
│ Fiber v2.42.0 │
│ http://127.0.0.1:3000 │
│ (bound on host 0.0.0.0 and port 3000) │
│ │
│ Handlers ............. 3 Processes ........... 1 │
│ Prefork ....... Disabled PID ............. 10724 │
└───────────────────────────────────────────────────┘
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
13:06:48 | 200 | 0s | 172.31.249.205 | GET | /api/v1/test
Fiber Version
2.42.2
Checklist:
Bug Description
This works
while this cause race condition:
How to Reproduce
and do
seq 1 200 | xargs -n1 -P20 curl "http://172.31.240.1:3000/api/v1/test"Expected Behavior
Fiber Version
2.42.2
Checklist: