redux-requests icon indicating copy to clipboard operation
redux-requests copied to clipboard

Should we clear errors on request actions?

Open klis87 opened this issue 3 years ago • 7 comments

Right now we do it, but I feel we shouldn't. We don't clear data, so I think we shouldn't error too. It would be cleared anyway on success, and the user will always have a choice whether to render error during loading new request or not. Right now error is gone on loading, so displaying it then without copying error as local state is not possible.

klis87 avatar Jan 02 '21 23:01 klis87

We would agree with that sentiment. We're currently facing the problem that our server returns a 500 and the JS only sees "Internal Server Error", while the server actually delivers a useful response with a proper error object. We currently have no easy way of inspecting that error or displaying it to the user.

image

Flixbox avatar Jan 05 '21 08:01 Flixbox

@Flixbox what driver do you use? Did you try console.log this error in the app? as tools might not display it properly due to serializing issues. Anyway, is it related to this issue? If not, please create a dedicated one so this would be only about clearing error on request :)

klis87 avatar Jan 05 '21 08:01 klis87

my guess is you use fetch driver, indeed we might have a small hole here, but status code 500 is not used often for predictable errors, 500+ usually means network error, random server failure and so on, if my assumptions are correct, just switching to 4xx status code will fix this problem

klis87 avatar Jan 05 '21 09:01 klis87

I see now that your original post is not related to my issue at all. I will do more troubleshooting and open a new issue as needed.

Flixbox avatar Jan 05 '21 13:01 Flixbox

I don't have any use case in mind particularly where error is still needed on (re)load which would result in "keep the current implementation as it is" but indeed i can see the benefit of keeping error until success which maybe helps someone.

This is a breaking change (if an implementation explicitly depends on how error behaves).

iwan-uschka avatar Jan 17 '21 22:01 iwan-uschka

@iwan-uschka It would be needed if you wanted to show error still during sth is refetched. This really depends on the app and use-case, but the thing is, changing this will just give this extra flexibility.

Agreed this is a breaking change, so probably this will go to next major version, not before. I could add it now with an extra config option, but I don't feel like this is important enough to justify it.

klis87 avatar Jan 17 '21 22:01 klis87

...extra flexibility

Agree.

...this is important enough to justify it

Agree.

iwan-uschka avatar Jan 17 '21 22:01 iwan-uschka