-
Notifications
You must be signed in to change notification settings - Fork 440
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
Handling requests w/ 400/500 status code #836
Comments
Actually, I misread the source code. If you return a proper sentinel w/ a The example code above does this ( It should be noted that this is not the default behavior of the netflix http-datasource, which returns an error object, rather than an error sentinel (see this issue). But creating a datasource interface that handles these cases is pretty easy. |
For the record, returning a Also, it appears sentinel metadata (beyond $type) is not actually preserved. So in the above example, |
nm, if I'd actually read the docs, So, looks like with some minimal tweaks to the http-datasource, setting the expiry metadata will keep errors out of the cache. Closing. |
What are the available options for handling server errors that are thrown before the request even makes it to the falcor router middleware? I'm thinking specifically of 500 network errors and 401 authentication errors.
The problem I'm running into is that if the datasource emits an error event for a request, the model will correctly emit that same error, but will also populate the cache w/ error sentinels for all nodes in the expected jsonGraph response. So, subsequent requests for those same resources (e.g. to try again in the case of a network error, or after the user has logged in in the case of an auth error) hit the cache, don't bother making the request again, and return the error sentinels.
For some types of errors, this might make sense. But in plenty of cases (authorization, network errors, etc.), the expectation is that the request could work if tried again, and so the error sentinels shouldn't be cached.
What I had hoped to do was add
$expires
metadata to the response sentinels in the datasource, e.g. (pseudo-ish code)...but the datasource expects values to be emitted, not the boxed sentinels, meaning no metadata
can be attached.
Wondering what other recommended approaches there are.
The text was updated successfully, but these errors were encountered: