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

Possible infinite loop when location2action returns multiple actions #3

Closed
rgrempel opened this issue Oct 3, 2015 · 0 comments
Closed
Assignees

Comments

@rgrempel
Copy link
Owner

rgrempel commented Oct 3, 2015

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.

  • You could, in theory, have multiple URLs which map to the same set of actions (that is, multiple URLs that do the same thing). It might even be sensible (in the "be liberal in what you accept, and strict in what you emit" sense).
  • Currently when we see a new URL and run location2action, the resulting action will typically generate a state change, which will run delta2update. Now, delta2update will produce a canonical URL for the state, which might be different from the URL we originally saw.
  • Currently, the canonical URL would then actually be set, if it is different from the URL in the location bar. You might consider this a feature or a bug -- it's a feature, in that you get the canonical URL. But, it's a bug in that you might not want that -- you especially might not want a new history entry.
  • But, once I apply the fix, the canonical URL won't be computed right away, since delta2update will be disabled while the location2action actions are being sent.

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.

@rgrempel rgrempel self-assigned this Oct 3, 2015
jerith666 added a commit to jerith666/elbum that referenced this issue Aug 9, 2018
hopefully then we can do all the model updates in one pass, satisfying
the assumptions of rgrempel/elm-route-url#3
jerith666 added a commit to jerith666/elbum that referenced this issue Aug 11, 2018
hopefully then we can do all the model updates in one pass, satisfying
the assumptions of rgrempel/elm-route-url#3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant