-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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]: Partial config cause race condition #2396
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Thx for the report |
What might fix the problem: Reason: The |
thx that works, will create a pr for this fix |
I wonder why this wasn't caught by our race-tests (for example in CI). We might also want to add a testcase for this specific case. |
In order to avoid the problem we should start and switch to never returning anonymous functions (closures) but return non-anonymous functions instead so no data is shared — never. For middlewares this might look as follows: // New creates a new middleware handler
func New(config ...Config) fiber.Handler {
// Setup, etc.
// Return new handler
return newMiddlewareHandler(list, shared, data, here)
} |
middleware/logger: Fix #2396, data race logger middleware
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:
The text was updated successfully, but these errors were encountered: