Skip to content

Commit

Permalink
fix: move response body check after 204 check
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Sep 20, 2023
1 parent 0186b45 commit c196c5c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ export function createEventSource(
onConnect()

const {body, redirected, status} = response
if (!body) {
throw new Error('Missing response body')
}

// HTTP 204 means "close the connection, no more data will be sent"
if (status === 204) {
Expand All @@ -177,6 +174,10 @@ export function createEventSource(
return
}

if (!body) {
throw new Error('Missing response body')
}

if (redirected) {
currentUrl = response.url
}
Expand Down

0 comments on commit c196c5c

Please sign in to comment.