Skip to content

Commit

Permalink
fix: Add debug error for streaming fail
Browse files Browse the repository at this point in the history
  • Loading branch information
otomir23 committed May 12, 2024
1 parent 4d501f9 commit 7c43c67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ export const fetchStream = async (url: string) => {
const data = await fetch(url)

if (!data.ok) {
const error = await data.json() as unknown
return genericErrorSchema.parse(error)
const error = await data.json().catch(() => null) as unknown
const body = genericErrorSchema.safeParse(error)
if (!body.success) {
throw new Error(`streaming from ${new URL(url).host} failed`)
}
return body.data
}

const contentDisposition = data.headers.get("Content-Disposition")
Expand Down

0 comments on commit 7c43c67

Please sign in to comment.