Inconsistent render behavior when fetch rejects with net::ERR_SSL_PROTOCOL_ERROR
See original GitHub issueDescribe the bug
The fetch api can reject its returned promise if the server it is fetching data from returns an invalid certificate. While this behavior should result in the <Get>
rendering it’s error
section, I instead see the progress indicator. While not 100% sure, I believe this is caused by the following line: https://github.com/contiamo/restful-react/blob/v5.2.1/src/Get.tsx#L202 as I figured there was some await
call without a catch
.
To Reproduce
Option 1:
If this ends up sharing correctly, this should be located here: https://codesandbox.io/s/9p3wmx7po
Option 2:
If using react-scripts, you should be able to switch some api call from http://...
to https://...
.
<RestfulProvider base="https://localhost:8080">
<Get path="/some/api/pets">
{(pets, { loading, error }) =>
loading ? (
Loading...
) : (
<div>
You should only see this after things are loaded.
{error ? (
<div>"OH NO!"</div>
) : (
<div>success!</div>
)}
</div>
)}
</Get>
</RestfulProvider>
Option 3:
- Create a server that returns a different certificate than the domain used to query it (Subject Alternative Name or Common Name is different)
- Send a GET request to this server
- observe UI behavior
Expected behavior
If the GET request fails because in invalid certificates, the error
section should render.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: OSX Darwin Kernel Version 15.6.0
- Browser Chrome
- Version
v5.2.1
Additional context
There might be other edge cases (maybe CORS or timeouts?) that cause this same behavior though I don’t have any evidence of that.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
@jgensler8, that’s a little strange. Here’s my output from
npm test
onmaster
:Ah! Good catch! I have discovered the issues after cleaning out my
node_modules
and treating the project as a fresh clone. I’ll fix up some things and get back to you. Thank you for letting us know about this!If it’s a 200 and the content is available without error, I don’t really see the point to handle this as an error. For now I think it’s should be ok like this, I’ve added a real try/catch on
fetch
in #97 for network error so it should be more reliable 😃I will close this issue for now, if you have any edge case where we have an error or anything that are not caught correctly, please open a new issue.
Thanks for the reporting and your reactivity, it’s really appreciate 💯