Skip to content

Commit

Permalink
fix: uncaught abort throw
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Dec 20, 2024
1 parent ac4deec commit de35a68
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions constants/SSEFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ export class SSEFetch {
this.abortController = new AbortController()
const body = values.method === 'POST' ? { body: values.body } : {}

const res = await fetch(values.endpoint, {
signal: this.abortController.signal,
method: values.method,
headers: values.headers,
...body,
})
try {
const res = await fetch(values.endpoint, {
signal: this.abortController.signal,
method: values.method,
headers: values.headers,
...body,
})

if (res.status !== 200 || !res.body) return this.onError()
this.closeStream = res.body.cancel
for await (const chunk of res.body) {
Expand Down

0 comments on commit de35a68

Please sign in to comment.