I encountered the same error. This error occurs when using the response, not when awaiting fetch()
. To handle the terminated error
, you should enclose the code that uses the response in a try catch
like below.
async function getResponse(url: string) {
try {
const res = await fetch(url)
if (!res.ok) return
return Buffer.from(await res.arrayBuffer()) // may occur `terminated error`
} catch (err) {/*...*/}
}