Skip to content

Commit

Permalink
Make sure 400-500 level HTTP sub-requests are not cached (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
blittle authored Mar 26, 2024
1 parent 44ac882 commit 73b4dc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shy-houses-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

Make sure 400-500 sub-requests are not cached
3 changes: 2 additions & 1 deletion packages/hydrogen/src/cache/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function fromSerializableResponse([body, init]: [any, ResponseInit]) {

// Check if the response body has GraphQL errors
// https://spec.graphql.org/June2018/#sec-Response-Format
export const checkGraphQLErrors = (body: any) => !body?.errors;
export const checkGraphQLErrors = (body: any, response: Response) =>
!body?.errors && response.status < 400;

// Lock to prevent revalidating the same sub-request
// in the same isolate. Note that different isolates
Expand Down

0 comments on commit 73b4dc8

Please sign in to comment.