Skip to content

Commit 44d50dd

Browse files
fix(fetch-error-handler): don't treat 304 responses as errors
`Response.ok` is only `true` for a 2xx response, but we don't want to throw for 304 responses. this is only a problem for apps that are sending `if-modified-since` or `if-none-match` headers, which is rare, but happens to be done by `@apollo/datasource-rest` in `cp-content-pipeline`.
1 parent 46b7466 commit 44d50dd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/fetch-error-handler/lib/create-handler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ function createFetchErrorHandler(options = {}) {
144144
}
145145

146146
// If the response isn't OK, we start throwing errors
147-
if (!response.ok) {
147+
// 304 is considered non-OK by fetch, but we don't consider that an error
148+
if (!response.ok && response.status !== 304) {
148149
// Parse the response URL so we can use the hostname in error messages
149150
let responseHostName = 'unknown';
150151
if (typeof response.url === 'string') {

0 commit comments

Comments
 (0)