app
app copied to clipboard
Error responses occasionally being cached by `cached` utility
We use cached
to fetch data either from cache or source of truth. There is currently no mechanism that prevents it from caching error responses returned by fetch functions that don't throw. This may result in error responses being cached, which then breaks the app until the cache key in question expires.
We need to ensure:
- Ideally, fetch functions passed to
cached
thoroughly validate the data they return - All fetch functions must throw if an error is encountered, even if said error is only visible by examining the response (e.g. checking
Response.ok
key) -
cached
must throw if the fetch function does, and not persist anything on Redis