-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
echo.Reverse
can have nondeterministic output
#1237
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Not sure we can do much about this. We should change the way we associate names with routes, which I'm pretty sure it would be a backward incompatible change. Maybe we can improve the documentation instead to list the limitations of this function (if they aren't mentioned already) ? Thoughts @im-kulikov @vishr ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Issue Description
With echo v3.3.8 (and probably other versions), it's possible for
echo.Reverse
to return nondeterministic results due to its implementation. If you define two routes that both map to the same handler function, multiple calls toecho.Reverse
on the handler function can result in different outputs.Checklist
Expected behaviour
Calling
echo.Reverse
on a handler function always results in the same output, whether that is all of the routes that map to a given handler, or the first one found.Actual behaviour
Calling
echo.Reverse
on a handler function can result in different outputs each time it is called.Steps to reproduce
Create a handler function and two routes that map to it (method is irrelevant, since
echo.Reverse
does not use it). Callecho.Reverse
on the handler function many times in a loop and observe that the output may change. See code below as well. This happens becauseecho.Reverse
iterates amap[string]*Route
to find a match, and iterating a map in Go produces elements of the map in an arbitrary order.Working code to debug
Version/commit
I am using version =3.3.8
The text was updated successfully, but these errors were encountered: