-
Notifications
You must be signed in to change notification settings - Fork 26
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
Handling failed single-page app navs #47
Comments
This includes ones generated by intercepting the navigate event with event.respondWith(). However, the promise passed to event.respondWith() is still useful for signaling the navigation's successful or unsuccessful completion. That is used to fuel browser UI, such as the loading spinner, as well as promises and events. And a rejected promise passed to event.respondWith() will roll back the navigation. Closes #19. Closes #44. Still some discussion to be had on the failure case in #47.
I lean towards the do-less model as well. It seems to me that if we can mirror cross-document navigations, we get some benefit in a simplified model. I do think we need new hooks though, like a navigatefailed event or something, as you mention. |
Would a |
In #60 I added some code examples to use |
The design of navigation interception, especially after #46 lands, leads to a novel situation. Namely, you can perform a single-page app navigation which fails, by passing a rejected promise to
event.respondWith()
. A somewhat-realistic example might be:The current plan as of #46 is that, because of the issues discussed in #19, all such navigations will synchronously succeed, but then asynchronously fail. Roughly:
location.href
, the URL bar, etc. immediately start pointing to/foo
, as if you'd donehistory.pushState(null, null, "/foo")
.appHistory.current
, as well as the underlying session history model, gets pointed to a new history entry for/foo
.location.href
, the URL bar, etc. back to the original URL that initiated the navigation.appHistory.current
, as well as the previous session history model, navigates back to the previous session history entry./foo
created in step (2) gets thrown away.Is this the right model for when the
navigate
handler tells us the navigation failed?The main alternative, I think, is to do a lot less. I.e., do not try to provide a rollback; leave
location.href
, the URL bar, etc. on/foo
. Instead just signal to the app (e.g. with an event onwindow.appHistory
and/orwindow.appHistory.current
) that the promise rejected, and have the app handle that. The app could do its own rollback, perhaps. Or it could display a literal error page, like it might for a server-side 404.I'm kind of leaning toward this do-less model. What do people think?
The other alternative would be to go the route of (2) in #19 (comment), which would allow us to delay all the updating stuff until we're sure the promise fulfills. Then there would be no navigate-then-rollback; we'd just never move at all in a failure case.
The text was updated successfully, but these errors were encountered: