Description
That is, what should navigation.navigate()
return if you navigate to:
- A 204 or 205 response? In this case the browser will stay on the current page.
- A response with
Content-Disposition: attachment
? In this case the browser will start a download. - A response with a content-type the browser doesn't know how to handle directly? In this case the browser will either start a download or launch an external app.
I feel like we have a few options:
-
Count all of these as an aborted navigation error, i.e. the returned promise rejects with an
"AbortError"
DOMException
,navigateerror
fires, etc. The mental model here is thatnavigation.navigate(url)
is a request to go tourl
, and if we don't end up onurl
, we failed. -
Count the 204/205 case as an aborted navigation error, but count the others as successful navigations which fulfill the promise and fire
navigatesuccess
once the download starts or the response is handed off. The mental model here is in the 204/205 case literally nothing got accomplished, so that's a failure, but in the other cases you succeeded at something, even if the URL didn't update. -
Count all of these cases as a success. The mental model here is that we got to the end of the navigation process without errors (204/205 are technically success status codes!) so we should signal as such.
Related:
-
Add the ability to navigate to a download or form submission #82 suggests adding an explicit
navigation.navigate(url, { download: true })
. We'd certainly want that to treat getting a download response as a success. And probably a 204/205 as a failure? -
Add the ability to navigate to a download or form submission #82 also allows a different model, where if you don't pass
{ download: true }
, and the server sendsContent-Disposition: attachment
, we either ignore the server (novel capability; might be dangerous) or we abort the navigation without doing any download (and return failure). -
These cases are especially strange because so far we only resolve the returned promise/fire the events for same-document navigations, on the reasoning that for a cross-document navigation, the page is going away anyway. But in these cases the page is not going away, so we should really give either a success or failure instead of leaving things hanging. If we do what is suggested in Should appHistory.navigate()'s returned promise settle for cross-document navigations? #95 then this all becomes more uniform and we're always resolving the promise.