-
Notifications
You must be signed in to change notification settings - Fork 195
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
Dispatch failure FSA when fetch fails #175
Conversation
e68c94f
to
fda1dc5
Compare
First off, I love this lib! 🎉 Second, I personally welcome this change :). Checking for the However, this is a pretty big breaking change, since now FAILURE actions can return the the do you think there would be a way to support a "classic" mode of sorts? I wouldn't want it included if it added a lot of overhead, but might help with migration from 2 -> 3 among community :) |
@@ -160,7 +160,7 @@ function apiMiddleware({ getState }) { | |||
return next( | |||
await actionWith( | |||
{ | |||
...requestType, | |||
...failureType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a "migration" helper option could exist? like:
...(options.legacyRequestError ? requestType : failureType),
maybe until v4 or something, although not sure if anyone else might find this useful, can always stick with v2 till you're ready for migration too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to a migration helper, but I don't know what the right approach is here. A breaking change that:
- requires you to go in and add a
legacyRequestError: true
to yourRSAA
s as a temporary fix
OR
- requires you to update your error handling paths to this new spec
I lean towards the latter but can be convinced otherwise!
OK, I've just bumped into this on my first run-through with the library (because my API isn't accessible right this second - I figured I'd boot it up when I got the code working). Obviously, things are fine as they are right now (now that I'm checking for Just adding my tuppence, and eagerly awaiting 3.0 🙃 Edit: just reading through the Lifecyle in the README, and while in a lot of cases it would be sufficient to dispatch a I can see us potentially using re-dispatching an |
Agree :) although as things stand, the Request FSA w/ What would a test look like for the new Failure FSA case for EDIT: looks like we could also use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been a bit distracted but want to pick this back up and get this change out!
Thanks for the great feedback @craig0990 + @darthrellimnad. Can you share any idea or samples of how you think this PR could be extended to give more information about what type of error happened?
@@ -160,7 +160,7 @@ function apiMiddleware({ getState }) { | |||
return next( | |||
await actionWith( | |||
{ | |||
...requestType, | |||
...failureType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to a migration helper, but I don't know what the right approach is here. A breaking change that:
- requires you to go in and add a
legacyRequestError: true
to yourRSAA
s as a temporary fix
OR
- requires you to update your error handling paths to this new spec
I lean towards the latter but can be convinced otherwise!
fda1dc5
to
ebf15ec
Compare
ebf15ec
to
96b0691
Compare
Merging this into the |
I can't quite remember exactly what I was thinking when I wrote the earlier comment :P I think it was around the fact that my API code had failed, but I had naively expected the A Here's an example of me handling the
By having the Hope that clarifies :) |
@craig0990 thanks. I hope this change makes exactly that possible! It's currently in the I'll leave an update here when that happens 🍎 |
This has been released in |
This is a follow-up to #175, which updated this behavior and docs for failed fetches, to include failures in RSAA custom methods, such as `[RSAA].headers`
Previously:
RSAA -> Request FSA -> Request Error FSA
Now:
RSAA -> Request FSA -> Failure FSA
Closes #26 #44 #99