You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 to echo.Reverse on the handler function can result in different outputs.
Checklist
Dependencies installed
No typos
Searched existing issues and docs
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). Call echo.Reverse on the handler function many times in a loop and observe that the output may change. See code below as well. This happens because echo.Reverse iterates a map[string]*Route to find a match, and iterating a map in Go produces elements of the map in an arbitrary order.
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: