Skip to content

Commit

Permalink
Fix serialization of error responses (#1091)
Browse files Browse the repository at this point in the history
The `Response` object used in `NetworkResponseError` has no enumerable properties – this results on an empty object being serialized `{}`.

Subsequent calls to the cache that retrieve this object will then fail to correctly return the expected status code (which is read via `CacheFirstDataSource._getFromCachedData`).
  • Loading branch information
fmrsabino authored Jan 30, 2024
1 parent 153e2ec commit 11bb359
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/datasources/cache/cache.first.data.source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export class CacheFirstDataSource {
): Promise<void> {
return this.cacheService.set(
cacheDir,
JSON.stringify(error),
JSON.stringify({
data: error.data,
response: { status: error.response.status },
url: error.url,
}),
notFoundExpireTimeSeconds,
);
}
Expand Down

0 comments on commit 11bb359

Please sign in to comment.