-
Notifications
You must be signed in to change notification settings - Fork 194
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
Two consecutive request
FSAs dispatched on network error
#25
Comments
@sgoll Thank you for the report and the detailed analysis. When arriving at this beta, I first wrote the documentation, reflecting what I wanted As you can probably guess by the fact that I haven't been able to respond to several issues over the last month or so, I have been very busy—and will continue to be for a couple of weeks. I'll look carefully into it as soon as I can. A PR might actually help me reason about it quick, so I'd very much welcome it. |
@agraboso any chance we could arrive at a |
@barrystaes: How is #43 applicable here? It does not seem to address the issue at hand. |
Whoops typo, i meant to link to the other PR: #26 |
Contrary to the documentation, the current implementation dispatches two consecutive
request
FSAs when a network error occurs.In
README.md
it says in section "Lifecycle", bullet point no. 3:The important thing to note here is "a different request FSA (…) instead of the one described above".
However, the actual code in
src/middleware.js
sends tworequest
FSAs in case of exceptions thrown during thefetch
call:This is problematic as we now cannot be sure which of the two
request
FSAs is which, or rather: once the non-errorrequest
FSA has fired, we should be able to assume that the request is either handled successfully, i.e. asuccess
FSA shows up, or fails with afailure
FSA. Receiving anotherrequest
FSA, now with error set, is counter-intuitive (and doesn't match the documentation).However, I'm not really sure how best to proceed from here. Since the
fetch
call can fail for all kinds of reasons, even late in the request (server accepted but then closed connection unexpectedly), it seems impossible to simply delay the first, non-errorrequest
FSA until we can be sure that no error will be thrown.Instead, we should probably always send a
failure
FSA, i.e. both when the server responds with a status code other than 2xx and when a network error occurs. In this case, it would be sufficient to change the documentation and simply replacerequestType
in the code above withfailureType
.Incidentally, this seems to also match the documentation regarding Failure Type Descriptors where the code sample shows the following if-check:
In the current implementation, the
res
argument tometa
is always set. With the proposed change, it would either be set (server responded with code other than 2xx) or unset (network error occurred).In case this issue is accepted, please let me know if I should prepare a pull request for the proposed change (documentation and code).
The text was updated successfully, but these errors were encountered: