rgrempel / elm-route-url

Router for single-page-apps in Elm
http://package.elm-lang.org/packages/rgrempel/elm-route-url/latest
MIT License
196 stars 16 forks source link

Possible infinite loop when location2action returns multiple actions #3

Closed rgrempel closed 8 years ago

rgrempel commented 8 years ago

As of version 1.0.2, there can be an infinite loop when location2action returns multiple actions. The reason is that each of the actions was triggering a call to delta2update (since each action produced a new state). Now, normally we would detect when delta2update produces a URL that is already set. However, in this case there are two, separate changes. The net result after the two changes would be the same. However, we don't detect that, and the infinite loop begins ...

I've got a fix almost ready that keeps track of when we're sending the actions to the address, and basically turns off delta2update while that is happening.

This does involve a slightly wider behaviour change in the following circumstances.

Now, I suppose the canonical URL will be computed whenever the next "normal" action occurs (that is, not computed by location2action), so perhaps that is soon enough? If not, there are some slightly fancier changes I could make to ensure that the canonical URL is computed immediately -- I'll leave that for now, though.