Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug]: Immutable configuration in Fiber not working as expected #3236

Open
3 tasks done
rebaz94 opened this issue Dec 7, 2024 · 6 comments
Open
3 tasks done

Comments

@rebaz94
Copy link

rebaz94 commented Dec 7, 2024

Bug Description

The Immutable configuration option in Fiber, when set to true, is intended to ensure that certain request values (e.g., request bodies) are immutable and accessible beyond the handler's lifecycle. However, enabling this option does not work as expected, resulting in data race errors when the request body is processed within a differernt goroutine.

Documentation Says:

When set to true, this relinquishes the 0-allocation promise in certain cases in order to access the handler values (e.g., request bodies) in an immutable fashion so that these values are available even if you return from the handler.

Am I missing something here, or is this the expected behavior, and I need to manually copy the body to ensure immutability in my code?

How to Reproduce

  1. Create a Fiber app with the Immutable and StreamRequestBody configurations set to true
app := fiber.New(fiber.Config{
    Immutable:         true,
    StreamRequestBody: true,
})
  1. Define a route where the request body is processed in new goroutine:
app.Get("/keep", func(c *fiber.Ctx) error {
    body := c.Body() // Supposed to be immutable
    go func() {
        for i := 0; i < 100; i++ {
            time.Sleep(time.Second)
            var data map[string]any
            err := json.Unmarshal(body, &data)
            fmt.Println(err, data) // Accessing body in a goroutine
        }
    }()
    return c.JSON(map[string]any{"success": true})
})
  1. send multiple concurrent requests
curl --request GET 'http://localhost:8080/keep' \
--header 'Content-Type: application/json' \
--data-raw '{"key": "val"}'

Expected Behavior

The request body c.Body() should remain immutable and safe to access across goroutines without causing data races but actually get a data races

==================
WARNING: DATA RACE
Read at 0x00c00011a080 by goroutine 76:
  encoding/json.checkValid()
  ...
Previous write at 0x00c00011a080 by goroutine 75:
  runtime.slicecopy()
  ...
==================

Fiber Version

v2.52.5

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.
@gaby
Copy link
Member

gaby commented Dec 7, 2024

This is probably happening in v3 too.

@rebaz94
Copy link
Author

rebaz94 commented Dec 17, 2024

@gaby there’s also a data race occurring when storing a reference to fiber.Ctx, even if the request hasn’t been closed yet. This often happens when adding breakpoints in the IDE.

Is there a way to determine if the request has been closed and the fiber.Ctx is no longer valid?

@gaby
Copy link
Member

gaby commented Dec 17, 2024

@rebaz94 We probably missing it somewhere else.

@gaby
Copy link
Member

gaby commented Dec 18, 2024

@rebaz94 Can you share the logs of the data race?

@rebaz94
Copy link
Author

rebaz94 commented Dec 21, 2024

Apologies for the delayed response. Here's a video demonstrating how you can reproduce the issue:

Screen.Recording.2024-12-22.at.2.04.59.AM.mp4

Here the logs

==================
WARNING: DATA RACE
Read at 0x00c0003f23a8 by goroutine 29:
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x40
  github.com/valyala/fasthttp.(*RequestCtx).String()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:896 +0x9c

Previous write at 0x00c0003f23a8 by goroutine 28:
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0xb8
  github.com/gofiber/fiber/v2.(*Ctx).String()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1878 +0x114

Goroutine 29 (running) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54

Goroutine 28 (finished) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54
==================
==================
WARNING: DATA RACE
Write at 0x00c0003eb830 by goroutine 29:
  runtime.slicecopy()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/runtime/slice.go:355 +0x0
  github.com/valyala/fasthttp.(*URI).appendSchemeHost()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:826 +0x154
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:816 +0x64
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/valyala/fasthttp.(*RequestCtx).String()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:896 +0x9c

Previous read at 0x00c0003eb830 by goroutine 28:
  runtime.slicecopy()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/runtime/slice.go:355 +0x0
  fmt.(*buffer).write()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/print.go:104 +0x154
  fmt.(*fmt).pad()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/format.go:95 +0xd4
  fmt.(*fmt).fmtBs()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/format.go:368 +0x98
  fmt.(*pp).fmtBytes()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/print.go:537 +0x17c
  fmt.(*pp).printArg()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/print.go:743 +0x808
  fmt.(*pp).doPrintf()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/print.go:1074 +0x974
  fmt.Sprintf()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/fmt/print.go:239 +0x80
  github.com/gofiber/fiber/v2.(*Ctx).String()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1872 +0x450

Goroutine 29 (running) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54

Goroutine 28 (finished) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54
==================
==================
WARNING: DATA RACE
Read at 0x00c0003f23c0 by goroutine 29:
  github.com/valyala/fasthttp.(*URI).RequestURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:684 +0x1d8
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x88
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/valyala/fasthttp.(*RequestCtx).String()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:896 +0x9c

Previous write at 0x00c0003f23c0 by goroutine 28:
  github.com/valyala/fasthttp.(*URI).RequestURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:693 +0x660
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x88
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/gofiber/fiber/v2.(*Ctx).String()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1878 +0x114

Goroutine 29 (running) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54

Goroutine 28 (finished) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54
==================
==================
WARNING: DATA RACE
Write at 0x00c0003f4058 by goroutine 29:
  github.com/valyala/fasthttp.appendQuotedPath()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/bytesconv.go:293 +0x464
  github.com/valyala/fasthttp.(*URI).RequestURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:684 +0x250
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x88
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/valyala/fasthttp.(*RequestCtx).String()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:896 +0x9c

Previous read at 0x00c0003f4058 by goroutine 28:
  runtime.slicecopy()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/runtime/slice.go:355 +0x0
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x194
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/gofiber/fiber/v2.(*Ctx).String()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1878 +0x114

Goroutine 29 (running) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54

Goroutine 28 (finished) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54
==================
==================
WARNING: DATA RACE
Write at 0x00c0003eb845 by goroutine 29:
  runtime.slicecopy()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/runtime/slice.go:355 +0x0
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x194
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/valyala/fasthttp.(*RequestCtx).String()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:896 +0x9c

Previous write at 0x00c0003eb845 by goroutine 28:
  runtime.slicecopy()
      ../swiftybase/pkg/mod/golang.org/[email protected]/src/runtime/slice.go:355 +0x0
  github.com/valyala/fasthttp.(*URI).AppendBytes()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:817 +0x194
  github.com/valyala/fasthttp.(*URI).FullURI()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/uri.go:810 +0x88
  github.com/gofiber/fiber/v2.(*Ctx).String()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1878 +0x114

Goroutine 29 (running) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54

Goroutine 28 (finished) created at:
  runtime.debugCallWrap()
      <autogenerated>:1 +0x10
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.useApiHandler.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:108 +0x7a8
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.baseMiddleware.func1()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/route_handler.go:21 +0x17c
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1030 +0x1bc
  github.com/swiftytime/swiftybase/pkg/swifty_cb/pkg/server.New.func2()
      ../swiftybase/swiftybase/pkg/swifty_cb/pkg/server/server.go:141 +0x63c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/cors.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/cors/cors.go:173 +0x27c
  github.com/gofiber/fiber/v2.(*Ctx).Next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/ctx.go:1027 +0x178
  github.com/gofiber/fiber/v2/middleware/recover.New.func1()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/middleware/recover/recover.go:43 +0x258
  github.com/gofiber/fiber/v2.(*App).next()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:145 +0x55c
  github.com/gofiber/fiber/v2.(*App).handler()
      ../swiftybase/pkg/mod/github.com/swiftytime/fiber/[email protected]/router.go:172 +0x1e8
  github.com/gofiber/fiber/v2.(*App).handler-fm()
      <autogenerated>:1 +0x48
  github.com/valyala/fasthttp.(*Server).serveConn()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/server.go:2385 +0x1ac8
  github.com/valyala/fasthttp.(*Server).serveConn-fm()
      <autogenerated>:1 +0x58
  github.com/valyala/fasthttp.(*workerPool).workerFunc()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:225 +0xec
  github.com/valyala/fasthttp.(*workerPool).getCh.func1()
      ../swiftybase/pkg/mod/github.com/valyala/[email protected]/workerpool.go:197 +0x54
==================

@gaby
Copy link
Member

gaby commented Dec 23, 2024

@rebaz94 Found the issue, it's related to String() implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants